From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-9.cisco.com (rcdn-iport-9.cisco.com [173.37.86.80]) by dpdk.org (Postfix) with ESMTP id 8C7582C69 for ; Wed, 25 May 2016 22:18:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2570; q=dns/txt; s=iport; t=1464207530; x=1465417130; h=from:to:cc:subject:date:message-id; bh=oWdA8Yvl/ywTAA4j/fysLD5jkFQTp2LrapFwoPppM6w=; b=YMNdImMwrt7YdwnCRiREM6mvPxTvqvssuH3DVpHn2lrMTUquU1xCiGE1 FtWZ6JnGsPNyVSPU8XrYAD1v5Mvf8bMMTlN7dYV9P395j66oLeDtiQpbs 7j5+1TclCSbM6EUyv9OCVgqbk3kDCT2z2p/AoUipu6fAiD/Q3gC7vll1D U=; X-IronPort-AV: E=Sophos;i="5.26,365,1459814400"; d="scan'208";a="106077510" Received: from rcdn-core-7.cisco.com ([173.37.93.143]) by rcdn-iport-9.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 May 2016 20:18:49 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-core-7.cisco.com (8.14.5/8.14.5) with ESMTP id u4PKInWF011039; Wed, 25 May 2016 20:18:49 GMT Received: by cisco.com (Postfix, from userid 392789) id 877173FAADC3; Wed, 25 May 2016 13:18:49 -0700 (PDT) From: John Daley To: dev@dpdk.org Cc: John Daley Date: Wed, 25 May 2016 13:18:34 -0700 Message-Id: <1464207514-4406-1-git-send-email-johndale@cisco.com> X-Mailer: git-send-email 2.7.0 Subject: [dpdk-dev] [PATCH] enic: fix seg fault when releasing queues X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 May 2016 20:18:50 -0000 If device configuration failed due to a lack of resources, like if there were more queues requested than available, the queue release function is called with NULL pointers which were being dereferenced. Skip releasing queues if they are NULL pointers. Also, if configuration fails due to lack of resources, be more specific about which resources are lacking. Fixes: fefed3d1e62c ("enic: new driver") Signed-off-by: John Daley --- drivers/net/enic/enic_main.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index bbbe660..a3eb4e3 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -467,14 +467,16 @@ int enic_alloc_intr_resources(struct enic *enic) void enic_free_rq(void *rxq) { - struct vnic_rq *rq = (struct vnic_rq *)rxq; - struct enic *enic = vnic_dev_priv(rq->vdev); + if (rxq != NULL) { + struct vnic_rq *rq = (struct vnic_rq *)rxq; + struct enic *enic = vnic_dev_priv(rq->vdev); - enic_rxmbuf_queue_release(enic, rq); - rte_free(rq->mbuf_ring); - rq->mbuf_ring = NULL; - vnic_rq_free(rq); - vnic_cq_free(&enic->cq[rq->index]); + enic_rxmbuf_queue_release(enic, rq); + rte_free(rq->mbuf_ring); + rq->mbuf_ring = NULL; + vnic_rq_free(rq); + vnic_cq_free(&enic->cq[rq->index]); + } } void enic_start_wq(struct enic *enic, uint16_t queue_idx) @@ -841,16 +843,22 @@ int enic_set_vnic_res(struct enic *enic) { struct rte_eth_dev *eth_dev = enic->rte_dev; - if ((enic->rq_count < eth_dev->data->nb_rx_queues) || - (enic->wq_count < eth_dev->data->nb_tx_queues)) { - dev_err(dev, "Not enough resources configured, aborting\n"); + if (enic->rq_count < eth_dev->data->nb_rx_queues) { + dev_err(dev, "Not enough Receive queues. Requested:%u, Configured:%u\n", + eth_dev->data->nb_rx_queues, enic->rq_count); + return -1; + } + if (enic->wq_count < eth_dev->data->nb_tx_queues) { + dev_err(dev, "Not enough Transmit queues. Requested:%u, Configured:%u\n", + eth_dev->data->nb_tx_queues, enic->wq_count); return -1; } enic->rq_count = eth_dev->data->nb_rx_queues; enic->wq_count = eth_dev->data->nb_tx_queues; if (enic->cq_count < (enic->rq_count + enic->wq_count)) { - dev_err(dev, "Not enough resources configured, aborting\n"); + dev_err(dev, "Not enough Completion queues. Required:%u, Configured:%u\n", + enic->rq_count + enic->wq_count, enic->cq_count); return -1; } -- 2.7.0