From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) by dpdk.org (Postfix) with ESMTP id 35F8BF72 for ; Thu, 26 Jul 2018 10:21:11 +0200 (CEST) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id w6Q8L6H2020985; Thu, 26 Jul 2018 01:21:07 -0700 From: Rahul Lakkireddy To: dev@dpdk.org Cc: shaguna@chelsio.com, nirranjan@chelsio.com, indranil@chelsio.com Date: Thu, 26 Jul 2018 13:49:32 +0530 Message-Id: <1532593172-10363-1-git-send-email-rahul.lakkireddy@chelsio.com> X-Mailer: git-send-email 2.5.3 Subject: [dpdk-dev] [PATCH] net/cxgbe: fix NULL deref in CLIP failure path X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jul 2018 08:21:11 -0000 From: Shagun Agrawal Fixes: 3f2c1e20 ("net/cxgbe: add Compressed Local IP region") Coverity issue: 302872 Signed-off-by: Shagun Agrawal Signed-off-by: Rahul Lakkireddy --- drivers/net/cxgbe/clip_tbl.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/cxgbe/clip_tbl.c b/drivers/net/cxgbe/clip_tbl.c index fa5281cd4..5e4dc5270 100644 --- a/drivers/net/cxgbe/clip_tbl.c +++ b/drivers/net/cxgbe/clip_tbl.c @@ -105,7 +105,7 @@ static struct clip_entry *t4_clip_alloc(struct rte_eth_dev *dev, struct adapter *adap = ethdev2adap(dev); struct clip_tbl *ctbl = adap->clipt; struct clip_entry *ce; - int ret; + int ret = 0; if (!ctbl) return NULL; @@ -120,12 +120,10 @@ static struct clip_entry *t4_clip_alloc(struct rte_eth_dev *dev, ce->type = FILTER_TYPE_IPV6; rte_atomic32_set(&ce->refcnt, 1); ret = clip6_get_mbox(dev, lip); - if (ret) { + if (ret) dev_debug(adap, "CLIP FW ADD CMD failed: %d", ret); - ce = NULL; - } } else { ce->type = FILTER_TYPE_IPV4; } @@ -136,7 +134,7 @@ static struct clip_entry *t4_clip_alloc(struct rte_eth_dev *dev, } t4_os_write_unlock(&ctbl->lock); - return ce; + return ret ? NULL : ce; } /** -- 2.14.1