Skip to content

Commit

Permalink
x86/cpu: Fix overrun check in arch_print_cpu_modalias()
Browse files Browse the repository at this point in the history
snprintf() does not return a negative value when truncating.

Signed-off-by: Ben Hutchings <[email protected]>
Acked-by: Thomas Renninger <[email protected]>
Acked-by: H. Peter Anvin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
bwhacks authored and gregkh committed Feb 13, 2012
1 parent da5a70f commit 70142a9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/x86/kernel/cpu/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ssize_t arch_print_cpu_modalias(struct device *dev,
for (i = 0; i < NCAPINTS*32; i++) {
if (boot_cpu_has(i)) {
n = snprintf(buf, size, ",%04X", i);
if (n < 0) {
if (n >= size) {
WARN(1, "x86 features overflow page\n");
break;
}
Expand Down

0 comments on commit 70142a9

Please sign in to comment.