bootconfig: Initialize ret in xbc_parse_tree()
Subsystems (2)
PATCH 1/1 bootconfig: Initialize ret in xbc_parse_tree()
From: "Steven Rostedt (VMware)" <[email protected]>
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.
--- lib/bootconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bootconfig.c +1 -1
@@ -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;
Signature · 1 line
2.31.1
Quoted 10 lines · On Wed, 27 Oct 2021 09:55:12 -0400 Steven Rostedt <[email protected]> wrote:
From: "Steven Rostedt (VMware)" <[email protected]>
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.
Quoted 3 lines
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)
Thank you,
Quoted 22 lines
Reported-by Andrew Morton <[email protected]>Signed-off-by Steven Rostedt (VMware) <[email protected]>--- lib/bootconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/bootconfig.c +1
-1@@ -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;Signature · 1 line
2.31.1
Signature · 1 line
Masami Hiramatsu <[email protected]>
Quoted 5 lines · On Wed, 27 Oct 2021 23:49:08 +0900 Masami Hiramatsu <[email protected]> wrote:
Thanks for fixing!
Looks good to me.Acked-by Masami Hiramatsu <[email protected]>
Thanks!
Quoted 9 lines
Quoted 4 lines
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