Skip to content

Commit

Permalink
bootconfig: Initialize ret in xbc_parse_tree()
Browse files Browse the repository at this point in the history
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.

Link: https://lkml.kernel.org/r/[email protected]

Fixes: bdac5c2 ("bootconfig: Allocate xbc_data inside xbc_init()")
Reported-by: kernel test robot <[email protected]>
Reported-by: Andrew Morton <[email protected]>
Acked-by: Masami Hiramatsu <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
  • Loading branch information
rostedt committed Oct 27, 2021
1 parent d33cc65 commit 39d9c1c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bootconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 39d9c1c

Please sign in to comment.