Skip to contentSkip to conversation

bootconfig: Fix to initialize 'ret' local variable

PATCH In review Masami Hiramatsu 2 participants 5 messages Oct 27, 2021

Subsystems (2)
lore
Share & tools
lore

Masami Hiramatsu

author maintainer
#0 lore raw

PATCH 1/1 bootconfig: Fix to initialize 'ret' local variable

Fix xbc_parse_tree() to initialize the 'ret' local variable before referring in the loop.

Fixes f3668cde8562 ("bootconfig: Split parse-tree part from xbc_init")
---
 lib/bootconfig.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bootconfig.c +1 -1
index a10ab25f6fcc..70e0d52ffd24 100644
@@ -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;
#1 lore raw
Quoted 7 lines · On Wed, 27 Oct 2021 22:54:28 +0900 Masami Hiramatsu <[email protected]> wrote:

Fix xbc_parse_tree() to initialize the 'ret' local variable before referring in the loop.

Fixes f3668cde8562 ("bootconfig: Split parse-tree part from xbc_init")

Heh, I just sent the exact same thing. But you have the wrong fixes tag I believe. As that change just moved the code, but the original location had the same issue I believe.

I'm fine taking yours instead. But I'd like to update the text explaining how the ret can be uninitialized and what happens if we set it to zero.

-- Steve

Quoted 17 lines
---
 lib/bootconfig.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bootconfig.c +1 -1
index a10ab25f6fcc..70e0d52ffd24 100644
@@ -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;
author maintainer
#2 lore raw
Quoted 6 lines · On Wed, 27 Oct 2021 10:01:26 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 3 lines · On Wed, 27 Oct 2021 22:54:28 +0900 Masami Hiramatsu <[email protected]> wrote:

Fix xbc_parse_tree() to initialize the 'ret' local variable before referring in the loop.

Quoted 8 lines
Quoted 4 lines
Fixes f3668cde8562 ("bootconfig: Split parse-tree part from xbc_init")

Heh, I just sent the exact same thing. But you have the wrong fixes tag I believe. As that change just moved the code, but the original location had the same issue I believe.

No, the original code uses the 'ret' for checking strlen().

+int __init xbc_init(char *buf)
+{
+ char *p, *q;
+ int ret, c;
+
+ if (xbc_data)
+ return -EBUSY;
+
+ ret = strlen(buf);
+ if (ret > XBC_DATA_MAX - 1 || ret == 0)
+ return -ERANGE;
+

OK, but my tag is also wrong, since this strlen() has been removed by commit bdac5c2b243f ("bootconfig: Allocate xbc_data inside xbc_init()")

So the correct tag is

Fixes bdac5c2b243f ("bootconfig: Allocate xbc_data inside xbc_init()")
Quoted 3 lines

I'm fine taking yours instead. But I'd like to update the text explaining how the ret can be uninitialized and what happens if we set it to zero.

Yeah, I'm also good for both, but the Fixes tag must be updated.

Thank you,

Quoted 22 lines

-- Steve

Quoted 17 lines
---
 lib/bootconfig.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bootconfig.c +1 -1
index a10ab25f6fcc..70e0d52ffd24 100644
@@ -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
Masami Hiramatsu <[email protected]>
#3 lore raw
Quoted 5 lines · On Wed, 27 Oct 2021 23:16:46 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 3 lines

I'm fine taking yours instead. But I'd like to update the text explaining how the ret can be uninitialized and what happens if we set it to zero.

Yeah, I'm also good for both, but the Fixes tag must be updated.

OK, I'll take mine then and update the fixes tag. Care to reply with a Reviewed-by tag?

Thanks,

-- Steve

author maintainer
#4 lore raw
Quoted 11 lines · On Wed, 27 Oct 2021 10:19:09 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 5 lines · On Wed, 27 Oct 2021 23:16:46 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 3 lines

I'm fine taking yours instead. But I'd like to update the text explaining how the ret can be uninitialized and what happens if we set it to zero.

Yeah, I'm also good for both, but the Fixes tag must be updated.

OK, I'll take mine then and update the fixes tag. Care to reply with a Reviewed-by tag?

Yes, sure, I sent it:)

Quoted 5 lines

Thanks,

-- Steve

Signature · 1 line
Masami Hiramatsu <[email protected]>