From: Rahul Lakkireddy Date: Fri, 27 Sep 2019 20:30:06 +0000 (+0530) Subject: net/cxgbe: avoid polling link status before device start X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=10fb9e47f6ec0093397b62f2c74f221719f967f4;p=dpdk.git net/cxgbe: avoid polling link status before device start Link updates come in firmware event queue, which is only created when device starts. So, don't poll for link status if firmware event queue is not yet created. This fixes NULL dereference when accessing non existent firmware event queue. Fixes: 265af08e75ba ("net/cxgbe: add link up and down ops") Cc: stable@dpdk.org Signed-off-by: Rahul Lakkireddy --- diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index 5d74f8ba3b..5df8d746c9 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -206,6 +206,9 @@ int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev, u8 old_link = pi->link_cfg.link_ok; for (i = 0; i < CXGBE_LINK_STATUS_POLL_CNT; i++) { + if (!s->fw_evtq.desc) + break; + cxgbe_poll(&s->fw_evtq, NULL, budget, &work_done); /* Exit if link status changed or always forced up */ @@ -239,6 +242,9 @@ int cxgbe_dev_set_link_up(struct rte_eth_dev *dev) struct sge *s = &adapter->sge; int ret; + if (!s->fw_evtq.desc) + return -ENOMEM; + /* Flush all link events */ cxgbe_poll(&s->fw_evtq, NULL, budget, &work_done); @@ -265,6 +271,9 @@ int cxgbe_dev_set_link_down(struct rte_eth_dev *dev) struct sge *s = &adapter->sge; int ret; + if (!s->fw_evtq.desc) + return -ENOMEM; + /* Flush all link events */ cxgbe_poll(&s->fw_evtq, NULL, budget, &work_done);