From 29490fe08d33d35f1ac037d905d68028e6e1a075 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 4 Nov 2016 21:14:21 +1030 Subject: [PATCH] cpuid: increment over size of cpu array, not just first one. Found by PCS Suite. Reported-by: Jon Griffiths Signed-off-by: Rusty Russell Signed-off-by: Ahmed Samy --- ccan/cpuid/cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccan/cpuid/cpuid.c b/ccan/cpuid/cpuid.c index 9a42d83e..4510def8 100644 --- a/ccan/cpuid/cpuid.c +++ b/ccan/cpuid/cpuid.c @@ -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; -- 2.39.2