Skip to contentSkip to conversation

net: wwan: iosm: fix potential memory leaks in ipc_imem_init()

PATCH Applied Abdun Nihaal 2 participants 2 messages May 19 – May 21

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: wwan: iosm: fix potential memory leaks in ipc_imem_init()

The memory allocated in ipc_protocol_init() is not freed on the error paths that follow in ipc_imem_init(). Fix that by calling the corresponding release function ipc_protocol_deinit() in the error path.

Fixes 3670970dd8c6 ("net: iosm: shared memory IPC interface")

---
v1->v2:
- Moved the ipc_protocol_deinit() call to a point after the tasklets and workers are cleaned up to avoid a possible Use after free, as suggested by Jakub Kicinski.

Link to v1 patch: https://lore.kernel.org/all/[email protected]/

 drivers/net/wwan/iosm/iosm_ipc_imem.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/wwan/iosm/iosm_ipc_imem.c +2 -0
index 1b7bc7d63a2e..4405c8531888 100644
@@ -1425,6 +1425,8 @@ struct iosm_imem *ipc_imem_init(struct iosm_pcie *pcie, unsigned int device_id,
 protocol_init_fail:
 	cancel_work_sync(&ipc_imem->run_state_worker);
 	ipc_task_deinit(ipc_imem->ipc_task);
+	if (ipc_imem->ipc_protocol)
+		ipc_protocol_deinit(ipc_imem->ipc_protocol);
 ipc_task_init_fail:
 	kfree(ipc_imem->ipc_task);
 ipc_task_fail:
Signature · 1 line
2.43.0
#1 lore raw
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 Tue, 19 May 2026 11:57:39 +0530 you wrote:

The memory allocated in ipc_protocol_init() is not freed on the error paths that follow in ipc_imem_init(). Fix that by calling the corresponding release function ipc_protocol_deinit() in the error path.

Fixes 3670970dd8c6 ("net: iosm: shared memory IPC interface")

[...]

Here is the summary with links:
- [net,v2] net: wwan: iosm: fix potential memory leaks in ipc_imem_init()

    https://git.kernel.org/netdev/net/c/c5d93b2c4035

You are awesome, thank you!

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