Skip to contentSkip to conversation

cpuid: increment over size of cpu array, not just first one.

PATCH New Rusty Russell 1 participant 1 message Nov 4, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpuid: increment over size of cpu array, not just first one.

Found by PCS Suite.

Reported-by Jon Griffiths
ccan/cpuid/cpuid.c +1 -1
index 9a42d83..4510def 100644
@@ -237,7 +237,7 @@ cputype_t cpuid_get_cpu_type(void)
 		uint32_t i;
 
 		get_cpuid(CPUID_VENDORID, &i, &u.bufu32[0], &u.bufu32[2], &u.bufu32[1]);
-		for (i = 0; i < sizeof(c_cpunames) / sizeof(c_cpunames); ++i) {
+		for (i = 0; i < sizeof(c_cpunames) / sizeof(c_cpunames[0]); ++i) {
 			if (strncmp(c_cpunames[i], u.buf, 12) == 0) {
 				cputype = (cputype_t)i;
 				break;

_______________________________________________
ccan mailing list
[email protected]
https://lists.ozlabs.org/listinfo/ccan