diff mbox series

[v2] net: stmmac: fix possible memory leak in stmmac_dvr_probe()

Message ID 20221212021350.3066631-1-cuigaosheng1@huawei.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series [v2] net: stmmac: fix possible memory leak in stmmac_dvr_probe() | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: bpf@vger.kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

cuigaosheng Dec. 12, 2022, 2:13 a.m. UTC
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>
---
v2:
- Add the missing errno, thanks!
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski Dec. 14, 2022, 3:15 a.m. UTC | #1
On Mon, 12 Dec 2022 10:13:50 +0800 Gaosheng Cui wrote:
> 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>

The previous version has already been applied and we can't remove it.
Could you send an incremental change to just add the errno?
cuigaosheng Dec. 14, 2022, 3:55 a.m. UTC | #2
Thanks for taking time to review this patch.

I am sorry I missed the errno, and I have submit a new patch to fix it.

Link: https://patchwork.kernel.org/project/netdevbpf/patch/20221214034205.3449908-1-cuigaosheng1@huawei.com/

On 2022/12/14 11:15, Jakub Kicinski wrote:
> On Mon, 12 Dec 2022 10:13:50 +0800 Gaosheng Cui wrote:
>> 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>
> The previous version has already been applied and we can't remove it.
> Could you send an incremental change to just add the errno?
> .
Jakub Kicinski Dec. 14, 2022, 3:57 a.m. UTC | #3
On Wed, 14 Dec 2022 11:55:27 +0800 cuigaosheng wrote:
> Thanks for taking time to review this patch.
> 
> I am sorry I missed the errno, and I have submit a new patch to fix it.
> 
> Link: https://patchwork.kernel.org/project/netdevbpf/patch/20221214034205.3449908-1-cuigaosheng1@huawei.com/

Perfect, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 18c7ca29da2c..46f51632c02a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -7096,7 +7096,8 @@  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;
+		ret = -ENOMEM;
+		goto error_wq_init;
 	}
 
 	INIT_WORK(&priv->service_task, stmmac_service_task);
@@ -7324,6 +7325,7 @@  int stmmac_dvr_probe(struct device *device,
 	stmmac_napi_del(ndev);
 error_hw_init:
 	destroy_workqueue(priv->wq);
+error_wq_init:
 	bitmap_free(priv->af_xdp_zc_qps);
 
 	return ret;