Skip to contentSkip to conversation

octeon_ep: Fix memory leak in octep_device_setup()

PATCH Applied Zilin Guan 3 participants 3 messages Jan 21 – Jan 23

Subsystems (3)
lore
Share & tools
lore

Zilin Guan

author
#0 lore raw

PATCH 1/1 octeon_ep: Fix memory leak in octep_device_setup()

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")
---
 drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +1 -1
index bcea3fc26a8c..57db7ea2f5be 100644
@@ -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);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · 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")
---
  drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +0 -0
index bcea3fc26a8c..57db7ea2f5be 100644

drivers/net/ethernet/marvell/octeon_ep/octep_main.c int octep_device_setup(struct octep_device *oct) · line 1344

Quoted 8 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +1 -1
@@ -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 lore raw
In reply to Zilin Guan
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · 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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html