Skip to content

Commit

Permalink
test_objagg: Uninitialized variable in error handling
Browse files Browse the repository at this point in the history
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: 9069a38 ("lib: objagg: implement optimization hints assembly and use hints for object creation")
Signed-off-by: Dan Carpenter <[email protected]>
Acked-by: Jiri Pirko <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Dan Carpenter authored and davem330 committed Feb 14, 2019
1 parent 951d3d6 commit e7c2e3b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/test_objagg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e7c2e3b

Please sign in to comment.