Skip to content

Commit bf3c068

Browse files
tititiou36gregkh
authored andcommitted
net/sonic: Fix a resource leak in an error handling path in 'jazz_sonic_probe()'
[ Upstream commit 10e3cc1 ] A call to 'dma_alloc_coherent()' is hidden in 'sonic_alloc_descriptors()', called from 'sonic_probe1()'. This is correctly freed in the remove function, but not in the error handling path of the probe function. Fix it and add the missing 'dma_free_coherent()' call. While at it, rename a label in order to be slightly more informative. Fixes: efcce83 ("[PATCH] macsonic/jazzsonic network drivers update") Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent fccb7bb commit bf3c068

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/ethernet/natsemi/jazzsonic.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,15 @@ static int jazz_sonic_probe(struct platform_device *pdev)
247247
goto out;
248248
err = register_netdev(dev);
249249
if (err)
250-
goto out1;
250+
goto undo_probe1;
251251

252252
printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
253253

254254
return 0;
255255

256-
out1:
256+
undo_probe1:
257+
dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
258+
lp->descriptors, lp->descriptors_laddr);
257259
release_mem_region(dev->base_addr, SONIC_MEM_SIZE);
258260
out:
259261
free_netdev(dev);

0 commit comments

Comments
 (0)