linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] allocate_flower_entry: should check for null deref
@ 2019-07-21  6:37 Navid Emamdoost
  2019-07-21 18:47 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Navid Emamdoost @ 2019-07-21  6:37 UTC (permalink / raw)
  Cc: kjlu, smccaman, secalert, emamd001, Navid Emamdoost,
	Vishal Kulkarni, David S. Miller, netdev, linux-kernel

allocate_flower_entry does not check for allocation success, but tries
to deref the result. I only moved the spin_lock under null check, because
 the caller is checking allocation's status at line 652.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
index 312599c6b35a..e447976bdd3e 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
@@ -67,7 +67,8 @@ static struct ch_tc_pedit_fields pedits[] = {
 static struct ch_tc_flower_entry *allocate_flower_entry(void)
 {
 	struct ch_tc_flower_entry *new = kzalloc(sizeof(*new), GFP_KERNEL);
-	spin_lock_init(&new->lock);
+	if (new)
+		spin_lock_init(&new->lock);
 	return new;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] allocate_flower_entry: should check for null deref
  2019-07-21  6:37 [PATCH] allocate_flower_entry: should check for null deref Navid Emamdoost
@ 2019-07-21 18:47 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-07-21 18:47 UTC (permalink / raw)
  To: navid.emamdoost
  Cc: kjlu, smccaman, secalert, emamd001, vishal, netdev, linux-kernel

From: Navid Emamdoost <navid.emamdoost@gmail.com>
Date: Sun, 21 Jul 2019 01:37:31 -0500

> allocate_flower_entry does not check for allocation success, but tries
> to deref the result. I only moved the spin_lock under null check, because
>  the caller is checking allocation's status at line 652.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-21 18:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-21  6:37 [PATCH] allocate_flower_entry: should check for null deref Navid Emamdoost
2019-07-21 18:47 ` David Miller

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