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 <ben@decadent.org.uk>
Acked-by: Thomas Renninger <trenn@suse.de>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Ben Hutchings authored and Greg Kroah-Hartman 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.