]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.12.14/net-systemport-free-dma-coherent-descriptors-on-errors.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.12.14 / net-systemport-free-dma-coherent-descriptors-on-errors.patch
CommitLineData
9ac87053
GKH
1From foo@baz Thu Sep 14 23:20:23 PDT 2017
2From: Florian Fainelli <f.fainelli@gmail.com>
3Date: Thu, 24 Aug 2017 16:01:13 -0700
4Subject: net: systemport: Free DMA coherent descriptors on errors
5
6From: Florian Fainelli <f.fainelli@gmail.com>
7
8
9[ Upstream commit c2062ee3d9615828109ffe8089fbf69bed394d05 ]
10
11In case bcm_sysport_init_tx_ring() is not able to allocate ring->cbs, we
12would return with an error, and call bcm_sysport_fini_tx_ring() and it
13would see that ring->cbs is NULL and do nothing. This would leak the
14coherent DMA descriptor area, so we need to free it on error before
15returning.
16
17Reported-by: Eric Dumazet <edumazet@gmail.com>
18Fixes: 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
19Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
20Signed-off-by: David S. Miller <davem@davemloft.net>
21Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22---
23 drivers/net/ethernet/broadcom/bcmsysport.c | 2 ++
24 1 file changed, 2 insertions(+)
25
26--- a/drivers/net/ethernet/broadcom/bcmsysport.c
27+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
28@@ -1342,6 +1342,8 @@ static int bcm_sysport_init_tx_ring(stru
29
30 ring->cbs = kcalloc(size, sizeof(struct bcm_sysport_cb), GFP_KERNEL);
31 if (!ring->cbs) {
32+ dma_free_coherent(kdev, sizeof(struct dma_desc),
33+ ring->desc_cpu, ring->desc_dma);
34 netif_err(priv, hw, priv->netdev, "CB allocation failed\n");
35 return -ENOMEM;
36 }