net: mvpp2: only free the TSO header buffers when it was allocated
authorAntoine Tenart <antoine.tenart@free-electrons.com>
Mon, 11 Dec 2017 08:13:25 +0000 (09:13 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 13 Dec 2017 16:16:50 +0000 (11:16 -0500)
This patch adds a check to only free the TSO header buffer when its
allocation previously succeeded.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/mvpp2.c

index 634b2f41cc9e43ef66d2cf2c33e393221b92af23..f203f085759682e484a7263cb5a2aa3f18ea22fa 100644 (file)
@@ -5802,6 +5802,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port,
                txq_pcpu->reserved_num = 0;
                txq_pcpu->txq_put_index = 0;
                txq_pcpu->txq_get_index = 0;
+               txq_pcpu->tso_headers = NULL;
 
                txq_pcpu->stop_threshold = txq->size - MVPP2_MAX_SKB_DESCS;
                txq_pcpu->wake_threshold = txq_pcpu->stop_threshold / 2;
@@ -5829,10 +5830,13 @@ static void mvpp2_txq_deinit(struct mvpp2_port *port,
                txq_pcpu = per_cpu_ptr(txq->pcpu, cpu);
                kfree(txq_pcpu->buffs);
 
-               dma_free_coherent(port->dev->dev.parent,
-                                 txq_pcpu->size * TSO_HEADER_SIZE,
-                                 txq_pcpu->tso_headers,
-                                 txq_pcpu->tso_headers_dma);
+               if (txq_pcpu->tso_headers)
+                       dma_free_coherent(port->dev->dev.parent,
+                                         txq_pcpu->size * TSO_HEADER_SIZE,
+                                         txq_pcpu->tso_headers,
+                                         txq_pcpu->tso_headers_dma);
+
+               txq_pcpu->tso_headers = NULL;
        }
 
        if (txq->descs)