Skip to contentSkip to conversation

s390/ctcm: Fix double-kfree

PATCH Applied Aswin Karuvally 3 participants 3 messages Nov 12, 2025 – Nov 18, 2025

Subsystems (4)
lore
Share & tools
lore

Aswin Karuvally

author maintainer
#0 lore raw

PATCH 1/1 s390/ctcm: Fix double-kfree

From: Aleksei Nikiforov <[email protected]>

The function 'mpc_rcvd_sweep_req(mpcginfo)' is called conditionally from function 'ctcmpc_unpack_skb'. It frees passed mpcginfo. After that a call to function 'kfree' in function 'ctcmpc_unpack_skb' frees it again.

Remove 'kfree' call in function 'mpc_rcvd_sweep_req(mpcginfo)'.

Bug detected by the clang static analyzer.

Fixes 0c0b20587b9f25a2 ("s390/ctcm: fix potential memory leak")
---
 drivers/s390/net/ctcm_mpc.c | 1 -
 1 file changed, 1 deletion(-)
drivers/s390/net/ctcm_mpc.c +0 -1
index 0aeafa772fb1..407b7c516658 100644
@@ -701,7 +701,6 @@ static void mpc_rcvd_sweep_req(struct mpcg_info *mpcginfo)
 
 	grp->sweep_req_pend_num--;
 	ctcmpc_send_sweep_resp(ch);
-	kfree(mpcginfo);
 	return;
 }
 
Signature · 1 line
2.48.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Aswin Karuvally

From: Aleksei Nikiforov <[email protected]>

The function 'mpc_rcvd_sweep_req(mpcginfo)' is called conditionally from function 'ctcmpc_unpack_skb'. It frees passed mpcginfo. After that a call to function 'kfree' in function 'ctcmpc_unpack_skb' frees it again.

Quoted 8 lines

Remove 'kfree' call in function 'mpc_rcvd_sweep_req(mpcginfo)'.

Bug detected by the clang static analyzer.

Fixes 0c0b20587b9f25a2 ("s390/ctcm: fix potential memory leak")

Thanks,

I agree with this analysis.
And this change brings mpc_rcvd_sweep_req() into line with other functions that ctcmpc_unpack_skb() passes mpcginfo - they don't free it either.

...

#2 lore raw
In reply to Aswin Karuvally
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 8 lines · On Wed, 12 Nov 2025 19:27:24 +0100 you wrote:

From: Aleksei Nikiforov <[email protected]>

The function 'mpc_rcvd_sweep_req(mpcginfo)' is called conditionally from function 'ctcmpc_unpack_skb'. It frees passed mpcginfo. After that a call to function 'kfree' in function 'ctcmpc_unpack_skb' frees it again.

[...]

Here is the summary with links:
- [net-next] s390/ctcm: Fix double-kfree

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

You are awesome, thank you!

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