]>
Commit | Line | Data |
---|---|---|
9ac87053 GKH |
1 | From foo@baz Thu Sep 14 23:20:23 PDT 2017 |
2 | From: Florian Fainelli <f.fainelli@gmail.com> | |
3 | Date: Thu, 24 Aug 2017 16:01:13 -0700 | |
4 | Subject: net: systemport: Free DMA coherent descriptors on errors | |
5 | ||
6 | From: Florian Fainelli <f.fainelli@gmail.com> | |
7 | ||
8 | ||
9 | [ Upstream commit c2062ee3d9615828109ffe8089fbf69bed394d05 ] | |
10 | ||
11 | In case bcm_sysport_init_tx_ring() is not able to allocate ring->cbs, we | |
12 | would return with an error, and call bcm_sysport_fini_tx_ring() and it | |
13 | would see that ring->cbs is NULL and do nothing. This would leak the | |
14 | coherent DMA descriptor area, so we need to free it on error before | |
15 | returning. | |
16 | ||
17 | Reported-by: Eric Dumazet <edumazet@gmail.com> | |
18 | Fixes: 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver") | |
19 | Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> | |
20 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
21 | Signed-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 | } |