Flexible I/O Tester development
 help / color / mirror / Atom feed
* [PATCH] cpuid: Null terminate x86 CPU string.
@ 2014-02-13  6:07 Sitsofe Wheeler
  2014-02-13 16:18 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Sitsofe Wheeler @ 2014-02-13  6:07 UTC (permalink / raw)
  To: fio@vger.kernel.org

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
---
 arch/arch-x86-common.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arch-x86-common.h b/arch/arch-x86-common.h
index 179572d..26a14a8 100644
--- a/arch/arch-x86-common.h
+++ b/arch/arch-x86-common.h
@@ -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"))
-- 
1.8.5.3

-- 
Sitsofe | http://sucs.org/~sits/

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpuid: Null terminate x86 CPU string.
  2014-02-13  6:07 [PATCH] cpuid: Null terminate x86 CPU string Sitsofe Wheeler
@ 2014-02-13 16:18 ` Jens Axboe
  2014-02-14 15:48   ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2014-02-13 16:18 UTC (permalink / raw)
  To: Sitsofe Wheeler; +Cc: fio@vger.kernel.org

On Thu, Feb 13 2014, Sitsofe Wheeler wrote:
> Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
> ---
>  arch/arch-x86-common.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arch-x86-common.h b/arch/arch-x86-common.h
> index 179572d..26a14a8 100644
> --- a/arch/arch-x86-common.h
> +++ b/arch/arch-x86-common.h
> @@ -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.

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpuid: Null terminate x86 CPU string.
  2014-02-13 16:18 ` Jens Axboe
@ 2014-02-14 15:48   ` Jens Axboe
  0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2014-02-14 15:48 UTC (permalink / raw)
  To: Sitsofe Wheeler; +Cc: fio@vger.kernel.org

On Thu, Feb 13 2014, Jens Axboe wrote:
> On Thu, Feb 13 2014, Sitsofe Wheeler wrote:
> > Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
> > ---
> >  arch/arch-x86-common.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/arch/arch-x86-common.h b/arch/arch-x86-common.h
> > index 179572d..26a14a8 100644
> > --- a/arch/arch-x86-common.h
> > +++ b/arch/arch-x86-common.h
> > @@ -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.

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:

diff --git a/arch/arch-x86-common.h b/arch/arch-x86-common.h
index 26a14a823750..31aa79f1b573 100644
--- a/arch/arch-x86-common.h
+++ b/arch/arch-x86-common.h
@@ -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"))

-- 
Jens Axboe



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-02-14 15:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-13  6:07 [PATCH] cpuid: Null terminate x86 CPU string Sitsofe Wheeler
2014-02-13 16:18 ` Jens Axboe
2014-02-14 15:48   ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox