]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: systemport: Fix memleak in bcm_sysport_probe
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Mon, 24 Aug 2020 05:58:31 +0000 (13:58 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Aug 2020 12:58:41 +0000 (05:58 -0700)
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>
drivers/net/ethernet/broadcom/bcmsysport.c

index dfed9ade6950ca8769f57e7470422822ebf63b7f..0762d5d1a810eb2a63d6fc88004ad94e11a4f4a3 100644 (file)
@@ -2491,8 +2491,10 @@ static int bcm_sysport_probe(struct platform_device *pdev)
        priv->tx_rings = devm_kcalloc(&pdev->dev, txq,
                                      sizeof(struct bcm_sysport_tx_ring),
                                      GFP_KERNEL);
-       if (!priv->tx_rings)
-               return -ENOMEM;
+       if (!priv->tx_rings) {
+               ret = -ENOMEM;
+               goto err_free_netdev;
+       }
 
        priv->is_lite = params->is_lite;
        priv->num_rx_desc_words = params->num_rx_desc_words;