From 39d9c1c103d3061ac94219ac12c04753860b337e Mon Sep 17 00:00:00 2001 From: "Steven Rostedt (VMware)" Date: Wed, 27 Oct 2021 10:57:53 -0400 Subject: 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/20211027105753.6ab9da5f@gandalf.local.home Fixes: bdac5c2b243f ("bootconfig: Allocate xbc_data inside xbc_init()") Reported-by: kernel test robot Reported-by: Andrew Morton Acked-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (VMware) --- lib/bootconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') 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; -- cgit v1.2.3-70-g09d2