public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] __init setup_early_printk: missing initialization
@ 2014-01-27 18:10 xypron.glpk
  2014-01-27 21:49 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: xypron.glpk @ 2014-01-27 18:10 UTC (permalink / raw)
  To: gxt; +Cc: akpm, paul.gortmaker, vapier, totglx, linux-kernel,
	Heinrich Schuchardt

From: Heinrich Schuchardt <xypron.glpk@gmx.de>

If is based on uninitialized value keep_early.
This leads to unpredictable result.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 arch/unicore32/kernel/early_printk.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/unicore32/kernel/early_printk.c b/arch/unicore32/kernel/early_printk.c
index 9be0d5d..460a3b6 100644
--- a/arch/unicore32/kernel/early_printk.c
+++ b/arch/unicore32/kernel/early_printk.c
@@ -35,7 +35,7 @@ static struct console early_ocd_console = {
 
 static int __init setup_early_printk(char *buf)
 {
-	int keep_early;
+	int keep_early = 0;
 
 	if (!buf || early_console)
 		return 0;
-- 
1.7.10.4


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

* Re: [PATCH 1/1] __init setup_early_printk: missing initialization
  2014-01-27 18:10 [PATCH 1/1] __init setup_early_printk: missing initialization xypron.glpk
@ 2014-01-27 21:49 ` Andrew Morton
  2014-01-27 22:58   ` Heinrich Schuchardt
  2014-01-28  8:05   ` 回复: " 管雪涛
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Morton @ 2014-01-27 21:49 UTC (permalink / raw)
  To: xypron.glpk; +Cc: gxt, paul.gortmaker, vapier, totglx, linux-kernel

On Mon, 27 Jan 2014 19:10:24 +0100 xypron.glpk@gmx.de wrote:

> From: Heinrich Schuchardt <xypron.glpk@gmx.de>
> 
> If is based on uninitialized value keep_early.
> This leads to unpredictable result.
> 
> ...
>
> --- a/arch/unicore32/kernel/early_printk.c
> +++ b/arch/unicore32/kernel/early_printk.c
> @@ -35,7 +35,7 @@ static struct console early_ocd_console = {
>  
>  static int __init setup_early_printk(char *buf)
>  {
> -	int keep_early;
> +	int keep_early = 0;
>  
>  	if (!buf || early_console)
>  		return 0;

yup.

But that code is quite overcooked.  How about this?

--- a/arch/unicore32/kernel/early_printk.c~arch-unicore32-kernel-early_printkc-setup_early_printk-missing-initialization-fix
+++ a/arch/unicore32/kernel/early_printk.c
@@ -35,17 +35,11 @@ static struct console early_ocd_console
 
 static int __init setup_early_printk(char *buf)
 {
-	int keep_early = 0;
-
 	if (!buf || early_console)
 		return 0;
 
-	if (strstr(buf, "keep"))
-		keep_early = 1;
-
 	early_console = &early_ocd_console;
-
-	if (keep_early)
+	if (strstr(buf, "keep"))
 		early_console->flags &= ~CON_BOOT;
 	else
 		early_console->flags |= CON_BOOT;
_


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

* Re: [PATCH 1/1] __init setup_early_printk: missing initialization
  2014-01-27 21:49 ` Andrew Morton
@ 2014-01-27 22:58   ` Heinrich Schuchardt
  2014-01-28  8:05   ` 回复: " 管雪涛
  1 sibling, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2014-01-27 22:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: gxt, paul.gortmaker, vapier, totglx, linux-kernel

On 27.01.2014 22:49, Andrew Morton wrote:
> On Mon, 27 Jan 2014 19:10:24 +0100 xypron.glpk@gmx.de wrote:
>
>> From: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>
>> If is based on uninitialized value keep_early.
>> This leads to unpredictable result.
>>
>> ...
>>
>> --- a/arch/unicore32/kernel/early_printk.c
>> +++ b/arch/unicore32/kernel/early_printk.c
>> @@ -35,7 +35,7 @@ static struct console early_ocd_console = {
>>
>>   static int __init setup_early_printk(char *buf)
>>   {
>> -	int keep_early;
>> +	int keep_early = 0;
>>
>>   	if (!buf || early_console)
>>   		return 0;
>
> yup.
>
> But that code is quite overcooked.  How about this?
>
> --- a/arch/unicore32/kernel/early_printk.c~arch-unicore32-kernel-early_printkc-setup_early_printk-missing-initialization-fix
> +++ a/arch/unicore32/kernel/early_printk.c
> @@ -35,17 +35,11 @@ static struct console early_ocd_console
>
>   static int __init setup_early_printk(char *buf)
>   {
> -	int keep_early = 0;
> -
>   	if (!buf || early_console)
>   		return 0;
>
> -	if (strstr(buf, "keep"))
> -		keep_early = 1;
> -
>   	early_console = &early_ocd_console;
> -
> -	if (keep_early)
> +	if (strstr(buf, "keep"))
>   		early_console->flags &= ~CON_BOOT;
>   	else
>   		early_console->flags |= CON_BOOT;
> _
>
>

Your code is easier to read, and has same functionality.

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

* 回复: Re: [PATCH 1/1] __init setup_early_printk: missing initialization
  2014-01-27 21:49 ` Andrew Morton
  2014-01-27 22:58   ` Heinrich Schuchardt
@ 2014-01-28  8:05   ` 管雪涛
  1 sibling, 0 replies; 4+ messages in thread
From: 管雪涛 @ 2014-01-28  8:05 UTC (permalink / raw)
  To: Andrew Morton
  Cc: xypron glpk, gxt, paul gortmaker, vapier, totglx, linux-kernel

Thanks.

Acked-by: Xuetao Guan <gxt@mprc.pku.edu.cn>

----- Andrew Morton <akpm@linux-foundation.org> 写道:
> On Mon, 27 Jan 2014 19:10:24 +0100 xypron.glpk@gmx.de wrote:
> 
> > From: Heinrich Schuchardt <xypron.glpk@gmx.de>
> > 
> > If is based on uninitialized value keep_early.
> > This leads to unpredictable result.
> > 
> > ...
> >
> > --- a/arch/unicore32/kernel/early_printk.c
> > +++ b/arch/unicore32/kernel/early_printk.c
> > @@ -35,7 +35,7 @@ static struct console early_ocd_console = {
> >  
> >  static int __init setup_early_printk(char *buf)
> >  {
> > -	int keep_early;
> > +	int keep_early = 0;
> >  
> >  	if (!buf || early_console)
> >  		return 0;
> 
> yup.
> 
> But that code is quite overcooked.  How about this?
> 
> --- a/arch/unicore32/kernel/early_printk.c~arch-unicore32-kernel-early_printkc-setup_early_printk-missing-initialization-fix
> +++ a/arch/unicore32/kernel/early_printk.c
> @@ -35,17 +35,11 @@ static struct console early_ocd_console
>  
>  static int __init setup_early_printk(char *buf)
>  {
> -	int keep_early = 0;
> -
>  	if (!buf || early_console)
>  		return 0;
>  
> -	if (strstr(buf, "keep"))
> -		keep_early = 1;
> -
>  	early_console = &early_ocd_console;
> -
> -	if (keep_early)
> +	if (strstr(buf, "keep"))
>  		early_console->flags &= ~CON_BOOT;
>  	else
>  		early_console->flags |= CON_BOOT;
> _
> 


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

end of thread, other threads:[~2014-01-28  8:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-27 18:10 [PATCH 1/1] __init setup_early_printk: missing initialization xypron.glpk
2014-01-27 21:49 ` Andrew Morton
2014-01-27 22:58   ` Heinrich Schuchardt
2014-01-28  8:05   ` 回复: " 管雪涛

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