netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net: stmmac: fix possible memory leak in stmmac_dvr_probe()
@ 2022-12-12  2:13 Gaosheng Cui
  2022-12-14  3:15 ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Gaosheng Cui @ 2022-12-12  2:13 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue, joabreu, davem, edumazet, kuba,
	pabeni, mcoquelin.stm32, ast, daniel, hawk, john.fastabend,
	boon.leong.ong, cuigaosheng1
  Cc: netdev, linux-stm32, linux-arm-kernel

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(-)

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;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] net: stmmac: fix possible memory leak in stmmac_dvr_probe()
  2022-12-12  2:13 [PATCH v2] net: stmmac: fix possible memory leak in stmmac_dvr_probe() Gaosheng Cui
@ 2022-12-14  3:15 ` Jakub Kicinski
  2022-12-14  3:55   ` cuigaosheng
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2022-12-14  3:15 UTC (permalink / raw)
  To: Gaosheng Cui
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, edumazet,
	pabeni, mcoquelin.stm32, ast, daniel, hawk, john.fastabend,
	boon.leong.ong, netdev, linux-stm32, linux-arm-kernel

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?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] net: stmmac: fix possible memory leak in stmmac_dvr_probe()
  2022-12-14  3:15 ` Jakub Kicinski
@ 2022-12-14  3:55   ` cuigaosheng
  2022-12-14  3:57     ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: cuigaosheng @ 2022-12-14  3:55 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, edumazet,
	pabeni, mcoquelin.stm32, ast, daniel, hawk, john.fastabend,
	boon.leong.ong, netdev, linux-stm32, linux-arm-kernel

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?
> .

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] net: stmmac: fix possible memory leak in stmmac_dvr_probe()
  2022-12-14  3:55   ` cuigaosheng
@ 2022-12-14  3:57     ` Jakub Kicinski
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2022-12-14  3:57 UTC (permalink / raw)
  To: cuigaosheng
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, edumazet,
	pabeni, mcoquelin.stm32, ast, daniel, hawk, john.fastabend,
	boon.leong.ong, netdev, linux-stm32, linux-arm-kernel

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!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-14  3:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-12  2:13 [PATCH v2] net: stmmac: fix possible memory leak in stmmac_dvr_probe() Gaosheng Cui
2022-12-14  3:15 ` Jakub Kicinski
2022-12-14  3:55   ` cuigaosheng
2022-12-14  3:57     ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).