public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] octeon_ep: Fix memory leak in octep_device_setup()
@ 2026-01-21 13:05 Zilin Guan
  2026-01-22 18:11 ` Vadim Fedorenko
  2026-01-23 19:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Zilin Guan @ 2026-01-21 13:05 UTC (permalink / raw)
  To: vburru
  Cc: sedara, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, jianhao.xu, Zilin Guan

In octep_device_setup(), if octep_ctrl_net_init() fails, the function
returns directly without unmapping the mapped resources and freeing the
allocated configuration memory.

Fix this by jumping to the unsupported_dev label, which performs the
necessary cleanup. This aligns with the error handling logic of other
paths in this function.

Compile tested only. Issue found using a prototype static analysis tool
and code review.

Fixes: 577f0d1b1c5f ("octeon_ep: add separate mailbox command and response queues")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
---
 drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
index bcea3fc26a8c..57db7ea2f5be 100644
--- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
+++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
@@ -1338,7 +1338,7 @@ int octep_device_setup(struct octep_device *oct)
 
 	ret = octep_ctrl_net_init(oct);
 	if (ret)
-		return ret;
+		goto unsupported_dev;
 
 	INIT_WORK(&oct->tx_timeout_task, octep_tx_timeout_task);
 	INIT_WORK(&oct->ctrl_mbox_task, octep_ctrl_mbox_task);
-- 
2.34.1


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

* Re: [PATCH net] octeon_ep: Fix memory leak in octep_device_setup()
  2026-01-21 13:05 [PATCH net] octeon_ep: Fix memory leak in octep_device_setup() Zilin Guan
@ 2026-01-22 18:11 ` Vadim Fedorenko
  2026-01-23 19:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2026-01-22 18:11 UTC (permalink / raw)
  To: Zilin Guan, vburru
  Cc: sedara, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, jianhao.xu

On 21/01/2026 13:05, Zilin Guan wrote:
> In octep_device_setup(), if octep_ctrl_net_init() fails, the function
> returns directly without unmapping the mapped resources and freeing the
> allocated configuration memory.
> 
> Fix this by jumping to the unsupported_dev label, which performs the
> necessary cleanup. This aligns with the error handling logic of other
> paths in this function.
> 
> Compile tested only. Issue found using a prototype static analysis tool
> and code review.
> 
> Fixes: 577f0d1b1c5f ("octeon_ep: add separate mailbox command and response queues")
> Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
> ---
>   drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> index bcea3fc26a8c..57db7ea2f5be 100644
> --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> @@ -1338,7 +1338,7 @@ int octep_device_setup(struct octep_device *oct)
>   
>   	ret = octep_ctrl_net_init(oct);
>   	if (ret)
> -		return ret;
> +		goto unsupported_dev;
>   
>   	INIT_WORK(&oct->tx_timeout_task, octep_tx_timeout_task);
>   	INIT_WORK(&oct->ctrl_mbox_task, octep_ctrl_mbox_task);

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>

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

* Re: [PATCH net] octeon_ep: Fix memory leak in octep_device_setup()
  2026-01-21 13:05 [PATCH net] octeon_ep: Fix memory leak in octep_device_setup() Zilin Guan
  2026-01-22 18:11 ` Vadim Fedorenko
@ 2026-01-23 19:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-23 19:50 UTC (permalink / raw)
  To: Zilin Guan
  Cc: vburru, sedara, andrew+netdev, davem, edumazet, kuba, pabeni,
	netdev, linux-kernel, jianhao.xu

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 21 Jan 2026 13:05:51 +0000 you wrote:
> In octep_device_setup(), if octep_ctrl_net_init() fails, the function
> returns directly without unmapping the mapped resources and freeing the
> allocated configuration memory.
> 
> Fix this by jumping to the unsupported_dev label, which performs the
> necessary cleanup. This aligns with the error handling logic of other
> paths in this function.
> 
> [...]

Here is the summary with links:
  - [net] octeon_ep: Fix memory leak in octep_device_setup()
    https://git.kernel.org/netdev/net/c/8016dc5ee19a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-01-23 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-21 13:05 [PATCH net] octeon_ep: Fix memory leak in octep_device_setup() Zilin Guan
2026-01-22 18:11 ` Vadim Fedorenko
2026-01-23 19:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox