public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bootconfig: Initialize ret in xbc_parse_tree()
@ 2021-10-27 13:55 Steven Rostedt
  2021-10-27 14:49 ` Masami Hiramatsu
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2021-10-27 13:55 UTC (permalink / raw)
  To: LKML; +Cc: Masami Hiramatsu, Andrew Morton

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

The do while loop continues while ret is zero, but ret is never
initialized. The check for ret in the loop at the while should always be
initialized, but if an empty string were to be passed in, q would be NULL
and p would be '\0', and it would break out of the loop without ever
setting ret.

Set ret to zero, and then xbc_verify_tree() would be called and catch that
it is an empty tree and report the proper error.

Cc: stable@vger.kernel.org
Fixes: 76db5a27a827c ("bootconfig: Add Extra Boot Config support")
Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/bootconfig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index a10ab25f6fcc..70e0d52ffd24 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -836,7 +836,7 @@ static int __init xbc_verify_tree(void)
 static int __init xbc_parse_tree(void)
 {
 	char *p, *q;
-	int ret, c;
+	int ret = 0, c;
 
 	last_parent = NULL;
 	p = xbc_data;
-- 
2.31.1


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

* Re: [PATCH] bootconfig: Initialize ret in xbc_parse_tree()
  2021-10-27 13:55 [PATCH] bootconfig: Initialize ret in xbc_parse_tree() Steven Rostedt
@ 2021-10-27 14:49 ` Masami Hiramatsu
  2021-10-27 14:53   ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Masami Hiramatsu @ 2021-10-27 14:49 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: LKML, Masami Hiramatsu, Andrew Morton

On Wed, 27 Oct 2021 09:55:12 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
> 
> The do while loop continues while ret is zero, but ret is never
> initialized. The check for ret in the loop at the while should always be
> initialized, but if an empty string were to be passed in, q would be NULL
> and p would be '\0', and it would break out of the loop without ever
> setting ret.
> 
> Set ret to zero, and then xbc_verify_tree() would be called and catch that
> it is an empty tree and report the proper error.

Thanks for fixing!
Looks good to me.

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>


> 
> Cc: stable@vger.kernel.org
> Fixes: 76db5a27a827c ("bootconfig: Add Extra Boot Config support")

Please update the Fixes tag (and remove Cc: stable, because below one
is still on the -next tree)

Fixes: bdac5c2b243f ("bootconfig: Allocate xbc_data inside xbc_init()")

Thank you,

> Reported-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
>  lib/bootconfig.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/bootconfig.c b/lib/bootconfig.c
> index a10ab25f6fcc..70e0d52ffd24 100644
> --- a/lib/bootconfig.c
> +++ b/lib/bootconfig.c
> @@ -836,7 +836,7 @@ static int __init xbc_verify_tree(void)
>  static int __init xbc_parse_tree(void)
>  {
>  	char *p, *q;
> -	int ret, c;
> +	int ret = 0, c;
>  
>  	last_parent = NULL;
>  	p = xbc_data;
> -- 
> 2.31.1
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* Re: [PATCH] bootconfig: Initialize ret in xbc_parse_tree()
  2021-10-27 14:49 ` Masami Hiramatsu
@ 2021-10-27 14:53   ` Steven Rostedt
  0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2021-10-27 14:53 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: LKML, Andrew Morton

On Wed, 27 Oct 2021 23:49:08 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> Thanks for fixing!
> Looks good to me.
> 
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
> 

Thanks!

> 
> > 
> > Cc: stable@vger.kernel.org
> > Fixes: 76db5a27a827c ("bootconfig: Add Extra Boot Config support")  
> 
> Please update the Fixes tag (and remove Cc: stable, because below one
> is still on the -next tree)
> 
> Fixes: bdac5c2b243f ("bootconfig: Allocate xbc_data inside xbc_init()")

Will do.

-- Steve


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

end of thread, other threads:[~2021-10-27 14:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-27 13:55 [PATCH] bootconfig: Initialize ret in xbc_parse_tree() Steven Rostedt
2021-10-27 14:49 ` Masami Hiramatsu
2021-10-27 14:53   ` Steven Rostedt

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