netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jiri Pirko <jiri@mellanox.com>
Cc: netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH 3/3 net-next] test_objagg: Uninitialized variable in error handling
Date: Wed, 13 Feb 2019 11:59:31 +0300	[thread overview]
Message-ID: <20190213085931.GD14113@kadam> (raw)
In-Reply-To: <20190213085650.GB14113@kadam>

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

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);
-- 
2.17.1


  parent reply	other threads:[~2019-02-13  8:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13  8:56 [PATCH 1/3 net-next] lib: objagg: Fix an error code in objagg_hints_get() Dan Carpenter
2019-02-13  8:58 ` [PATCH 2/3 net-next] test_objagg: Test the correct variable Dan Carpenter
2019-02-13 13:16   ` Jiri Pirko
2019-02-14  6:13   ` David Miller
2019-02-13  8:59 ` Dan Carpenter [this message]
2019-02-13 13:16   ` [PATCH 3/3 net-next] test_objagg: Uninitialized variable in error handling Jiri Pirko
2019-02-14  6:13   ` David Miller
2019-02-13 13:15 ` [PATCH 1/3 net-next] lib: objagg: Fix an error code in objagg_hints_get() Jiri Pirko
2019-02-14  6:13 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190213085931.GD14113@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=jiri@mellanox.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).