x86/cpu: Fix overrun check in arch_print_cpu_modalias()
authorBen Hutchings <ben@decadent.org.uk>
Sat, 11 Feb 2012 22:56:59 +0000 (22:56 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Feb 2012 23:24:26 +0000 (15:24 -0800)
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>
arch/x86/kernel/cpu/match.c

index 940e2d483076a67410939970648c81306b9c3bd5..2dfa52bcdfe2c91de4f0f526a3f5fa175590d898 100644 (file)
@@ -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;
                        }