All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jiri Pirko <jiri@mellanox.com>
Cc: netdev@vger.kernel.org, Ido Schimmel <idosch@mellanox.com>,
	kernel-janitors@vger.kernel.org
Subject: [PATCH 1/3 net-next] lib: objagg: Fix an error code in objagg_hints_get()
Date: Wed, 13 Feb 2019 08:56:50 +0000	[thread overview]
Message-ID: <20190213085650.GB14113@kadam> (raw)

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 <dan.carpenter@oracle.com>
---
 lib/objagg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/objagg.c b/lib/objagg.c
index 781f41c3c47d..d552ec9c60ed 100644
--- a/lib/objagg.c
+++ b/lib/objagg.c
@@ -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;
 
-- 
2.17.1

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jiri Pirko <jiri@mellanox.com>
Cc: netdev@vger.kernel.org, Ido Schimmel <idosch@mellanox.com>,
	kernel-janitors@vger.kernel.org
Subject: [PATCH 1/3 net-next] lib: objagg: Fix an error code in objagg_hints_get()
Date: Wed, 13 Feb 2019 11:56:50 +0300	[thread overview]
Message-ID: <20190213085650.GB14113@kadam> (raw)

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 <dan.carpenter@oracle.com>
---
 lib/objagg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/objagg.c b/lib/objagg.c
index 781f41c3c47d..d552ec9c60ed 100644
--- a/lib/objagg.c
+++ b/lib/objagg.c
@@ -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;
 
-- 
2.17.1

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

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13  8:56 Dan Carpenter [this message]
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  8:58   ` Dan Carpenter
2019-02-13 13:16   ` Jiri Pirko
2019-02-13 13:16     ` Jiri Pirko
2019-02-14  6:13   ` David Miller
2019-02-14  6:13     ` David Miller
2019-02-13  8:59 ` [PATCH 3/3 net-next] test_objagg: Uninitialized variable in error handling Dan Carpenter
2019-02-13  8:59   ` Dan Carpenter
2019-02-13 13:16   ` Jiri Pirko
2019-02-13 13:16     ` Jiri Pirko
2019-02-14  6:13   ` David Miller
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-13 13:15   ` Jiri Pirko
2019-02-14  6:13 ` David Miller
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=20190213085650.GB14113@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=idosch@mellanox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.