Skip to content

Commit 39d9c1c

Browse files
committed
bootconfig: Initialize ret in xbc_parse_tree()
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]>
1 parent d33cc65 commit 39d9c1c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/bootconfig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ static int __init xbc_verify_tree(void)
836836
static int __init xbc_parse_tree(void)
837837
{
838838
char *p, *q;
839-
int ret, c;
839+
int ret = 0, c;
840840

841841
last_parent = NULL;
842842
p = xbc_data;

0 commit comments

Comments
 (0)