Commit 70142a9d authored by Ben Hutchings's avatar Ben Hutchings Committed by Greg Kroah-Hartman

x86/cpu: Fix overrun check in arch_print_cpu_modalias()

snprintf() does not return a negative value when truncating.
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
Acked-by: default avatarThomas Renninger <trenn@suse.de>
Acked-by: default avatarH. Peter Anvin <hpa@zytor.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent da5a70f3
...@@ -67,7 +67,7 @@ ssize_t arch_print_cpu_modalias(struct device *dev, ...@@ -67,7 +67,7 @@ ssize_t arch_print_cpu_modalias(struct device *dev,
for (i = 0; i < NCAPINTS*32; i++) { for (i = 0; i < NCAPINTS*32; i++) {
if (boot_cpu_has(i)) { if (boot_cpu_has(i)) {
n = snprintf(buf, size, ",%04X", i); n = snprintf(buf, size, ",%04X", i);
if (n < 0) { if (n >= size) {
WARN(1, "x86 features overflow page\n"); WARN(1, "x86 features overflow page\n");
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment