lib: objagg: Fix an error code in objagg_hints_get()
Subsystems (5)
PATCH 1/3 lib: objagg: Fix an error code in objagg_hints_get()
We need to set the error code on this path otherwise we return ERR_PTR(0) which would result in a NULL dereference in the caller.
--- lib/objagg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/objagg.c +3 -1
@@ -968,8 +968,10 @@ struct objagg_hints *objagg_hints_get(struct objagg *objagg,if (err) goto err_fillup_hints; -if (WARN_ON (objagg_hints->node_count != objagg->obj_count)) +if (WARN_ON (objagg_hints->node_count != objagg->obj_count)) { + err = -EINVAL ; goto err_node_count_check; + }return objagg_hints;
Signature · 1 line
2.17.1
PATCH 2/3 test_objagg: Test the correct variable
There is a typo here. We intended to check "objagg2" but we instead test "objagg" which is not an error pointer.
--- lib/test_objagg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/test_objagg.c +2 -2
@@ -952,8 +952,8 @@ static int test_hints_case(const struct hints_case *hints_case) } objagg2 =objagg_create (&delta_ops, hints, &world2); -if (IS_ERR (objagg)) -return PTR_ERR (objagg); +if (IS_ERR (objagg2)) +return PTR_ERR (objagg2);for (i =0 ; i < hints_case->key_ids_count; i++) { objagg_obj = world_obj_get(&world2, objagg2,
Signature · 1 line
2.17.1
Re: [PATCH 2/3 net-next] test_objagg: Test the correct variable
Quoted 5 lines · Wed, Feb 13, 2019 at 09:58:20AM CET, [email protected] wrote:
There is a typo here. We intended to check "objagg2" but we instead test "objagg" which is not an error pointer.
Fixes 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")Signed-off-by Dan Carpenter <[email protected]>
Thanks.
Re: [PATCH 2/3 net-next] test_objagg: Test the correct variable
In reply to Dan CarpenterFrom: Dan Carpenter <[email protected]>
Date: Wed, 13 Feb 2019 11:58:20 +0300
Quoted 5 lines
There is a typo here. We intended to check "objagg2" but we instead test "objagg" which is not an error pointer.
Fixes 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")Signed-off-by Dan Carpenter <[email protected]>
Applied.
PATCH 3/3 test_objagg: Uninitialized variable in error handling
In reply to Dan CarpenterWe 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.
--- lib/test_objagg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/test_objagg.c +3 -2
@@ -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);
Signature · 1 line
2.17.1
Re: [PATCH 3/3 net-next] test_objagg: Uninitialized variable in error handling
Quoted 9 lines · Wed, Feb 13, 2019 at 09:59:31AM CET, [email protected] 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 <[email protected]>
Re: [PATCH 3/3 net-next] test_objagg: Uninitialized variable in error handling
In reply to Dan CarpenterFrom: Dan Carpenter <[email protected]>
Date: Wed, 13 Feb 2019 11:59:31 +0300
Quoted 9 lines
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 <[email protected]>
Applied.
Quoted 5 lines · Wed, Feb 13, 2019 at 09:56:50AM CET, [email protected] wrote:
We need to set the error code on this path otherwise we return
ERR_PTR(0)which would result in a NULL dereference in the caller.Fixes 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")Signed-off-by Dan Carpenter <[email protected]>
I have the same patch in my queue.
From: Dan Carpenter <[email protected]>
Date: Wed, 13 Feb 2019 11:56:50 +0300
Quoted 5 lines
We need to set the error code on this path otherwise we return
ERR_PTR(0)which would result in a NULL dereference in the caller.Fixes 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")Signed-off-by Dan Carpenter <[email protected]>
Applied.