cpuid: Null terminate x86 CPU string.
PATCH 1/1 cpuid: Null terminate x86 CPU string.
Signed-off-by Sitsofe Wheeler <[email protected]>
--- arch/arch-x86-common.h | 1 + 1 file changed, 1 insertion(+)
arch/arch-x86-common.h +1 -0
@@ -60,6 +60,7 @@ static inline int arch_init(char *envp[]) (unsigned int *) &str[8 ], (unsigned int *) &str[4]); + str[11 ] ='\0' ;if (!strcmp (str,"GenuineIntel" )) tsc_reliable =arch_init_intel (level);else if (!strcmp (str,"AuthenticAMD" ))
Signature · 4 lines
1.8.5.3 -- Sitsofe | http://sucs.org/~sits/
Jens Axboe
AppliedQuoted 10 lines · Sitsofe Wheeler
Signed-off-by Sitsofe Wheeler <[email protected]>--- arch/arch-x86-common.h | 1 + 1 file changed, 1 insertion(+)arch/arch-x86-common.h +0
-0
arch/arch-x86-common.h static inline int arch_init(char *envp[]) · line 66
Quoted 7 lines
arch/arch-x86-common.h +1
-0@@ -60,6 +60,7 @@ static inline int arch_init(char *envp[]) (unsigned int *) &str[8 ], (unsigned int *) &str[4]); + str[11 ] ='\0' ;if (!strcmp (str,"GenuineIntel" )) tsc_reliable =arch_init_intel (level);else if (!strcmp (str,"AuthenticAMD" ))
Applied, thanks.
Signature · 1 line
Jens Axboe
Quoted 14 lines · Jens Axboe
Quoted 13 lines · Sitsofe Wheeler
Signed-off-by Sitsofe Wheeler <[email protected]>--- arch/arch-x86-common.h | 1 + 1 file changed, 1 insertion(+)arch/arch-x86-common.h +0
-0@@ -60,6 +60,7 @@ static inline int arch_init(char *envp[]) (unsigned int *) &str[8 ], (unsigned int *) &str[4]);
Quoted 6 lines
arch/arch-x86-common.h static inline int arch_init(char *envp[]) · line 66
Quoted 4 lines
arch/arch-x86-common.h +1
-0+ str[11 ] ='\0' ;if (!strcmp (str,"GenuineIntel" )) tsc_reliable =arch_init_intel (level);else if (!strcmp (str,"AuthenticAMD" ))Applied, thanks.
Oops, this one was buggy - if we want the string null terminated, there needs to be room for 13 characters. It needs to look like this:
arch/arch-x86-common.h +2 -2
@@ -54,13 +54,13 @@ static inline int arch_init_amd(unsigned int level)static inline int arch_init (char *envp[]) {unsigned int level; -char str[12 ]; +char str[13 ];cpuid (0 , &level, (unsigned int *) &str[0 ], (unsigned int *) &str[8 ], (unsigned int *) &str[4 ]); - str[11 ] ='\0' ; + str[12 ] ='\0' ;if (!strcmp (str,"GenuineIntel" )) tsc_reliable =arch_init_intel (level);else if (!strcmp (str,"AuthenticAMD" ))
Signature · 1 line
Jens Axboe