net/qede: fix crash when configure fails

Message ID 37a7ac2b3c1522fd72e86bf11660f6c65880a8d6.1541777958.git.tredaelli@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/qede: fix crash when configure fails |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Timothy Redaelli Nov. 9, 2018, 3:45 p.m. UTC
  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 <tredaelli@redhat.com>
---
 drivers/net/qede/qede_rxtx.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
  

Comments

Mody, Rasesh Nov. 10, 2018, 12:39 a.m. UTC | #1
>From: Timothy Redaelli <tredaelli@redhat.com>
>Sent: Friday, November 09, 2018 7:46 AM
>
>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 <tredaelli@redhat.com>

Fix looks good to me.

Acked-by: Rasesh Mody <rasesh.mody@cavium.com>

Thanks!
-Rasesh
  
Ferruh Yigit Nov. 12, 2018, 12:09 p.m. UTC | #2
On 11/10/2018 12:39 AM, Mody, Rasesh wrote:
>> From: Timothy Redaelli <tredaelli@redhat.com>
>> Sent: Friday, November 09, 2018 7:46 AM
>>
>> 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 <tredaelli@redhat.com>
> 
> Fix looks good to me.
> 
> Acked-by: Rasesh Mody <rasesh.mody@cavium.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

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);