From patchwork Thu Jul 26 08:19:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Lakkireddy X-Patchwork-Id: 43399 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C38CA1C01; Thu, 26 Jul 2018 10:21:12 +0200 (CEST) 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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; } /**