summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/stmicro
diff options
context:
space:
mode:
authorGaosheng Cui <cuigaosheng1@huawei.com>2022-12-07 11:34:13 +0300
committerDavid S. Miller <davem@davemloft.net>2022-12-09 13:51:38 +0300
commita137f3f27f9290933fe7e40e6dc8a445781c31a2 (patch)
treeeedb74be0abceaf341d3d686dbdf12dd1548689f /drivers/net/ethernet/stmicro
parentf150b63f3fa5fdd81e0dd6151e8850268e29438c (diff)
downloadlinux-a137f3f27f9290933fe7e40e6dc8a445781c31a2.tar.xz
net: stmmac: fix possible memory leak in stmmac_dvr_probe()
The bitmap_free() should be called to free priv->af_xdp_zc_qps when create_singlethread_workqueue() fails, otherwise there will be a memory leak, so we add the err path error_wq_init to fix it. Fixes: bba2556efad6 ("net: stmmac: Enable RX via AF_XDP zero-copy") Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com> Reviewed-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/stmicro')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 23ec0a9e396c..b978d057c5f4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -7097,7 +7097,7 @@ int stmmac_dvr_probe(struct device *device,
priv->wq = create_singlethread_workqueue("stmmac_wq");
if (!priv->wq) {
dev_err(priv->device, "failed to create workqueue\n");
- return -ENOMEM;
+ goto error_wq_init;
}
INIT_WORK(&priv->service_task, stmmac_service_task);
@@ -7325,6 +7325,7 @@ error_mdio_register:
stmmac_napi_del(ndev);
error_hw_init:
destroy_workqueue(priv->wq);
+error_wq_init:
bitmap_free(priv->af_xdp_zc_qps);
return ret;