Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: systemport: Fix memleak in bcm_sysport_probe

When devm_kcalloc() fails, dev should be freed just
like what we've done in the subsequent error paths.

Fixes: 7b78be48a8eb6 ("net: systemport: Dynamically allocate number of TX rings")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Dinghao Liu and committed by
David S. Miller
7ef1fc57 100e3345

+4 -2
+4 -2
drivers/net/ethernet/broadcom/bcmsysport.c
··· 2491 2491 priv->tx_rings = devm_kcalloc(&pdev->dev, txq, 2492 2492 sizeof(struct bcm_sysport_tx_ring), 2493 2493 GFP_KERNEL); 2494 - if (!priv->tx_rings) 2495 - return -ENOMEM; 2494 + if (!priv->tx_rings) { 2495 + ret = -ENOMEM; 2496 + goto err_free_netdev; 2497 + } 2496 2498 2497 2499 priv->is_lite = params->is_lite; 2498 2500 priv->num_rx_desc_words = params->num_rx_desc_words;