diff mbox series

[3/3,net-next] test_objagg: Uninitialized variable in error handling

Message ID 20190213085931.GD14113@kadam
State Accepted
Delegated to: David Miller
Headers show
Series [1/3,net-next] lib: objagg: Fix an error code in objagg_hints_get() | expand

Commit Message

Dan Carpenter Feb. 13, 2019, 8:59 a.m. UTC
We need to set the error message on this path otherwise some of the
callers, such as test_hints_case(), print from an uninitialized pointer.

We had a similar bug earlier and set "errmsg" to NULL in the caller,
test_delta_action_item().  That code is no longer required so I have
removed it.

Fixes: 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 lib/test_objagg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Jiri Pirko Feb. 13, 2019, 1:16 p.m. UTC | #1
Wed, Feb 13, 2019 at 09:59:31AM CET, dan.carpenter@oracle.com wrote:
>We need to set the error message on this path otherwise some of the
>callers, such as test_hints_case(), print from an uninitialized pointer.
>
>We had a similar bug earlier and set "errmsg" to NULL in the caller,
>test_delta_action_item().  That code is no longer required so I have
>removed it.
>
>Fixes: 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")
>Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Jiri Pirko <jiri@mellanox.com>
David Miller Feb. 14, 2019, 6:13 a.m. UTC | #2
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 13 Feb 2019 11:59:31 +0300

> We need to set the error message on this path otherwise some of the
> callers, such as test_hints_case(), print from an uninitialized pointer.
> 
> We had a similar bug earlier and set "errmsg" to NULL in the caller,
> test_delta_action_item().  That code is no longer required so I have
> removed it.
> 
> Fixes: 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.
diff mbox series

Patch

diff --git a/lib/test_objagg.c b/lib/test_objagg.c
index 3dd45777b13c..72c1abfa154d 100644
--- a/lib/test_objagg.c
+++ b/lib/test_objagg.c
@@ -745,8 +745,10 @@  static int check_expect_stats(struct objagg *objagg,
 	int err;
 
 	stats = objagg_stats_get(objagg);
-	if (IS_ERR(stats))
+	if (IS_ERR(stats)) {
+		*errmsg = "objagg_stats_get() failed.";
 		return PTR_ERR(stats);
+	}
 	err = __check_expect_stats(stats, expect_stats, errmsg);
 	objagg_stats_put(stats);
 	return err;
@@ -786,7 +788,6 @@  static int test_delta_action_item(struct world *world,
 	if (err)
 		goto errout;
 
-	errmsg = NULL;
 	err = check_expect_stats(objagg, &action_item->expect_stats, &errmsg);
 	if (err) {
 		pr_err("Key %u: Stats: %s\n", action_item->key_id, errmsg);