From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id F2A3DA2EDB for ; Sat, 7 Sep 2019 00:00:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 93A6D1F4BD; Fri, 6 Sep 2019 23:59:59 +0200 (CEST) Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) by dpdk.org (Postfix) with ESMTP id D63BE1F495; Fri, 6 Sep 2019 23:59:57 +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 x86LxqZq004205; Fri, 6 Sep 2019 14:59:53 -0700 From: Rahul Lakkireddy To: dev@dpdk.org Cc: nirranjan@chelsio.com, stable@dpdk.org Date: Sat, 7 Sep 2019 03:22:27 +0530 Message-Id: X-Mailer: git-send-email 2.5.3 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 06/12] net/cxgbe: avoid polling link status before device start 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" 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. Cc: stable@dpdk.org Fixes: 265af08e75ba ("net/cxgbe: add link up and down ops") Signed-off-by: Rahul Lakkireddy --- drivers/net/cxgbe/cxgbe_ethdev.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index fb174f8d4..381dd273d 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -204,6 +204,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 */ @@ -237,6 +240,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); @@ -263,6 +269,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); -- 2.18.0