From: Shagun Agrawal Date: Thu, 26 Jul 2018 08:19:32 +0000 (+0530) Subject: net/cxgbe: fix null dereference on CLIP failure X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=217d1816265ddfff008436d7f019914b712aaffc;p=dpdk.git net/cxgbe: fix null dereference on CLIP failure Coverity issue: 302872 Fixes: 3f2c1e209cfc ("net/cxgbe: add Compressed Local IP region") Signed-off-by: Shagun Agrawal Signed-off-by: Rahul Lakkireddy --- diff --git a/drivers/net/cxgbe/clip_tbl.c b/drivers/net/cxgbe/clip_tbl.c index fa5281cd4d..5e4dc52704 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; } /**