fm10k: set pointer to NULL after free
authorMichael Qiu <michael.qiu@intel.com>
Fri, 6 Mar 2015 07:56:47 +0000 (15:56 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 16 Mar 2015 23:46:01 +0000 (00:46 +0100)
It could be a potential not safe issue.

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
Acked-by: Jing Chen <jing.d.chen@intel.com>
lib/librte_pmd_fm10k/fm10k_ethdev.c

index 62c4a39..0c7a80c 100644 (file)
@@ -142,9 +142,12 @@ rx_queue_free(struct fm10k_rx_queue *q)
        if (q) {
                PMD_INIT_LOG(DEBUG, "Freeing rx queue %p", q);
                rx_queue_clean(q);
-               if (q->sw_ring)
+               if (q->sw_ring) {
                        rte_free(q->sw_ring);
+                       q->sw_ring = NULL;
+               }
                rte_free(q);
+               q = NULL;
        }
 }
 
@@ -225,11 +228,16 @@ tx_queue_free(struct fm10k_tx_queue *q)
        if (q) {
                PMD_INIT_LOG(DEBUG, "Freeing tx queue %p", q);
                tx_queue_clean(q);
-               if (q->rs_tracker.list)
+               if (q->rs_tracker.list) {
                        rte_free(q->rs_tracker.list);
-               if (q->sw_ring)
+                       q->rs_tracker.list = NULL;
+               }
+               if (q->sw_ring) {
                        rte_free(q->sw_ring);
+                       q->sw_ring = NULL;
+               }
                rte_free(q);
+               q = NULL;
        }
 }