From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id D75E84C77; Fri, 9 Nov 2018 16:45:51 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A2B9F3084242; Fri, 9 Nov 2018 15:45:50 +0000 (UTC) Received: from aldebaran.drizzt.lan (dhcp189-71.ntdv.lab.eng.bos.redhat.com [10.19.189.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E4E719C65; Fri, 9 Nov 2018 15:45:48 +0000 (UTC) From: Timothy Redaelli To: Rasesh Mody , Harish Patil , Shahed Shaikh Cc: dev@dpdk.org, stable@dpdk.org Date: Fri, 9 Nov 2018 16:45:40 +0100 Message-Id: <37a7ac2b3c1522fd72e86bf11660f6c65880a8d6.1541777958.git.tredaelli@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 09 Nov 2018 15:45:51 +0000 (UTC) Subject: [dpdk-dev] [PATCH] net/qede: fix crash when configure fails 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: Fri, 09 Nov 2018 15:45:52 -0000 Currently, if configuration fails (for example if a 100G card is used with an odd number of RX/TX queues) QEDE crashes due to a null pointer dereference. This commit fixes it by checking that the pointer is not NULL before using it. Fixes: 7105b24f4bb8 ("net/qede: fix memory alloc for multiple port reconfig") Cc: stable@dpdk.org Signed-off-by: Timothy Redaelli --- drivers/net/qede/qede_rxtx.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c index 8a4772f46..296189107 100644 --- a/drivers/net/qede/qede_rxtx.c +++ b/drivers/net/qede/qede_rxtx.c @@ -235,12 +235,13 @@ static void qede_rx_queue_release_mbufs(struct qede_rx_queue *rxq) void qede_rx_queue_release(void *rx_queue) { struct qede_rx_queue *rxq = rx_queue; - struct qede_dev *qdev = rxq->qdev; - struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); - - PMD_INIT_FUNC_TRACE(edev); + struct qede_dev *qdev; + struct ecore_dev *edev; if (rxq) { + qdev = rxq->qdev; + edev = QEDE_INIT_EDEV(qdev); + PMD_INIT_FUNC_TRACE(edev); qede_rx_queue_release_mbufs(rxq); qdev->ops->common->chain_free(edev, &rxq->rx_bd_ring); qdev->ops->common->chain_free(edev, &rxq->rx_comp_ring); @@ -399,12 +400,13 @@ static void qede_tx_queue_release_mbufs(struct qede_tx_queue *txq) void qede_tx_queue_release(void *tx_queue) { struct qede_tx_queue *txq = tx_queue; - struct qede_dev *qdev = txq->qdev; - struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); - - PMD_INIT_FUNC_TRACE(edev); + struct qede_dev *qdev; + struct ecore_dev *edev; if (txq) { + qdev = txq->qdev; + edev = QEDE_INIT_EDEV(qdev); + PMD_INIT_FUNC_TRACE(edev); qede_tx_queue_release_mbufs(txq); qdev->ops->common->chain_free(edev, &txq->tx_pbl); rte_free(txq->sw_tx_ring); -- 2.19.1