summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom
diff options
context:
space:
mode:
authorDinghao Liu <dinghao.liu@zju.edu.cn>2020-08-24 07:58:31 +0200
committerDavid S. Miller <davem@davemloft.net>2020-08-24 14:58:41 +0200
commit7ef1fc57301f3cef7201497aa27e89ccb91737fe (patch)
treece44405b99eacb60edbffb7bf4c2cddac60a07fd /drivers/net/ethernet/broadcom
parentnet: hns: Fix memleak in hns_nic_dev_probe (diff)
downloadlinux-7ef1fc57301f3cef7201497aa27e89ccb91737fe.tar.xz
linux-7ef1fc57301f3cef7201497aa27e89ccb91737fe.zip
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>
Diffstat (limited to 'drivers/net/ethernet/broadcom')
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index dfed9ade6950..0762d5d1a810 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -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;