Johnny Hughes
2019-02-04 c1f36c28393a7bb126cbf436cd6a4077a5b5c313
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From ee5e257740c16b87408633288ee4247835ec2782 Mon Sep 17 00:00:00 2001
From: Antoine Tenart <antoine.tenart@free-electrons.com>
Date: Mon, 11 Dec 2017 09:13:25 +0100
Subject: [PATCH 16/46] net: mvpp2: only free the TSO header buffers when it
 was allocated
 
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>
(cherry picked from commit b70d4a5195c7193d1d55af791d9811477522e25a)
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
 drivers/net/ethernet/marvell/mvpp2.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
 
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 634b2f4..f203f08 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -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)
-- 
2.7.4