Skip to content

Commit c2062ee

Browse files
ffainellidavem330
authored andcommitted
net: systemport: Free DMA coherent descriptors on errors
In case bcm_sysport_init_tx_ring() is not able to allocate ring->cbs, we would return with an error, and call bcm_sysport_fini_tx_ring() and it would see that ring->cbs is NULL and do nothing. This would leak the coherent DMA descriptor area, so we need to free it on error before returning. Reported-by: Eric Dumazet <[email protected]> Fixes: 80105be ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver") Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d4fec85 commit c2062ee

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/ethernet/broadcom/bcmsysport.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,8 @@ static int bcm_sysport_init_tx_ring(struct bcm_sysport_priv *priv,
13461346

13471347
ring->cbs = kcalloc(size, sizeof(struct bcm_sysport_cb), GFP_KERNEL);
13481348
if (!ring->cbs) {
1349+
dma_free_coherent(kdev, sizeof(struct dma_desc),
1350+
ring->desc_cpu, ring->desc_dma);
13491351
netif_err(priv, hw, priv->netdev, "CB allocation failed\n");
13501352
return -ENOMEM;
13511353
}

0 commit comments

Comments
 (0)