net: gemini: Fix memory leak in gmac_setup_txqs
Subsystems (4)
PATCH 1/1 net: gemini: Fix memory leak in gmac_setup_txqs
In the implementation of gmac_setup_txqs() the allocated desc_ring is leaked if TX queue base is not aligned. Release it via dma_free_coherent.
--- drivers/net/ethernet/cortina/gemini.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/cortina/gemini.c +2 -0
@@ -576,6 +576,8 @@ static int gmac_setup_txqs(struct net_device *netdev)if (port->txq_dma_base & ~DMA_Q_BASE_MASK ) {dev_warn (geth->dev,"TX queue base is not aligned\n" ); +dma_free_coherent (geth->dev, len *sizeof (*desc_ring), + desc_ring, port->txq_dma_base);kfree (skb_tab);return -ENOMEM ; }
Signature · 1 line
2.17.1
drivers/net/ethernet/cortina/gemini.c static int gmac_setup_txqs(struct net_device *netdev) · line 583
Quoted 10 lines
+++
b/drivers/net/ethernet/cortina/gemini.cdrivers/net/ethernet/cortina/gemini.c +2
-0@@ -576,6 +576,8 @@ static int gmac_setup_txqs(struct net_device *netdev)if (port->txq_dma_base & ~DMA_Q_BASE_MASK ) {dev_warn (geth->dev,"TX queue base is not aligned\n" ); +dma_free_coherent (geth->dev, len *sizeof (*desc_ring), + desc_ring, port->txq_dma_base);kfree (skb_tab);return -ENOMEM ; }
The added function call seems to be fine.
Would you like to avoid a bit of duplicate code for the exception handling?
Regards,
Markus
Quoted 6 lines · Navid Emamdoost
In the implementation of
gmac_setup_txqs()the allocateddesc_ringis leaked if TX queue base is not aligned. Release it viadma_free_coherent.Fixes 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet")Signed-off-by Navid Emamdoost <[email protected]>
Looks correct to me,
Yours,
Linus Walleij
David Miller
maintainerFrom: Navid Emamdoost <[email protected]>
Date: Sat, 14 Dec 2019 19:10:44 -0600
Quoted 6 lines
In the implementation of
gmac_setup_txqs()the allocateddesc_ringis leaked if TX queue base is not aligned. Release it viadma_free_coherent.Fixes 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet")Signed-off-by Navid Emamdoost <[email protected]>
Applied and queued up for -stable, thanks.