From: Xiaoyun Wang Date: Thu, 14 May 2020 09:29:16 +0000 (+0800) Subject: net/hinic: fix queues resource free X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a2177d2e84c32fafb23f5863ef16ef1bf082d18f;p=dpdk.git net/hinic: fix queues resource free Adds tx_queues and rx_queues non-null judgment before free tx or rx resources, because some app may set tx_queues or rx_queues to be null before call free resource interfaces, which may cause a segfault. Fixes: 64727024d2fd ("net/hinic: add device initialization") Cc: stable@dpdk.org Signed-off-by: Xiaoyun Wang --- diff --git a/drivers/net/hinic/hinic_pmd_rx.c b/drivers/net/hinic/hinic_pmd_rx.c index 4ca74f0fb2..a49769a863 100644 --- a/drivers/net/hinic/hinic_pmd_rx.c +++ b/drivers/net/hinic/hinic_pmd_rx.c @@ -413,7 +413,8 @@ void hinic_free_all_rx_resources(struct rte_eth_dev *eth_dev) HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev); for (q_id = 0; q_id < nic_dev->num_rq; q_id++) { - eth_dev->data->rx_queues[q_id] = NULL; + if (eth_dev->data->rx_queues != NULL) + eth_dev->data->rx_queues[q_id] = NULL; if (nic_dev->rxqs[q_id] == NULL) continue; diff --git a/drivers/net/hinic/hinic_pmd_tx.c b/drivers/net/hinic/hinic_pmd_tx.c index 258f2c1c4a..996e0b26ff 100644 --- a/drivers/net/hinic/hinic_pmd_tx.c +++ b/drivers/net/hinic/hinic_pmd_tx.c @@ -1217,7 +1217,8 @@ void hinic_free_all_tx_resources(struct rte_eth_dev *eth_dev) HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev); for (q_id = 0; q_id < nic_dev->num_sq; q_id++) { - eth_dev->data->tx_queues[q_id] = NULL; + if (eth_dev->data->tx_queues != NULL) + eth_dev->data->tx_queues[q_id] = NULL; if (nic_dev->txqs[q_id] == NULL) continue;