Skip to contentSkip to conversation

lib: objagg: Fix an error code in objagg_hints_get()

PATCH Applied Dan Carpenter 3 participants 9 messages Feb 13, 2019 – Feb 14, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

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.

Fixes 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")
---
 lib/objagg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/objagg.c +3 -1
index 781f41c3c47d..d552ec9c60ed 100644
@@ -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
#1 lore raw

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.

Fixes 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")
---
 lib/test_objagg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/test_objagg.c +2 -2
index 3744573b6365..3dd45777b13c 100644
@@ -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
maintainer Acked-by on v1 2/3
#2 lore raw

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")

Thanks.

maintainer Applied
#3 lore raw

Re: [PATCH 2/3 net-next] test_objagg: Test the correct variable

In reply to Dan Carpenter

From: 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")

Applied.

#4 lore raw

PATCH 3/3 test_objagg: Uninitialized variable in error handling

In reply to Dan Carpenter

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")
---
 lib/test_objagg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/test_objagg.c +3 -2
index 3dd45777b13c..72c1abfa154d 100644
@@ -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
maintainer Acked-by on v1 3/3
#5 lore raw

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")
maintainer Applied
#6 lore raw

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

In reply to Dan Carpenter

From: 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")

Applied.

maintainer Acked-by on v1 1/3
#7 lore raw
In reply to Dan Carpenter
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")

I have the same patch in my queue.