net: mctp: put sock on tag allocation failure
Jeremy Kerr
maintainerPATCH 1/1 net: mctp: put sock on tag allocation failure
We may hold an extra reference on a socket if a tag allocation fails: we optimistically allocate the sk_key, and take a ref there, but do not drop if we end up not using the allocated key.
Ensure we're dropping the sock on this failure by doing a proper unref rather than directly kfree()ing.
--- net/mctp/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mctp/route.c +1 -1
@@ -663,7 +663,7 @@ struct mctp_sk_key *mctp_alloc_local_tag(struct mctp_sock *msk,spin_unlock_irqrestore (&mns->keys_lock, flags);if (!tagbits) { -kfree (key); +mctp_key_unref (key);return ERR_PTR (-EBUSY ); }
Signature · 1 line
2.39.2
Quoted 9 lines · Jeremy Kerr
We may hold an extra reference on a socket if a tag allocation fails: we optimistically allocate the
sk_key, and take a ref there, but do not drop if we end up not using the allocated key.Ensure we're dropping the sock on this failure by doing a proper unref rather than directly kfree()ing.
Fixes de8a6b15d965 ("net: mctp: add an explicit reference from a mctp_sk_key to sock")Signed-off-by Jeremy Kerr <[email protected]>
Jakub Kicinski
maintainerQuoted 9 lines · On Thu, 15 Feb 2024 15:53:08 +0800 Jeremy Kerr wrote:
We may hold an extra reference on a socket if a tag allocation fails: we optimistically allocate the
sk_key, and take a ref there, but do not drop if we end up not using the allocated key.Ensure we're dropping the sock on this failure by doing a proper unref rather than directly kfree()ing.
Fixes de8a6b15d965 ("net: mctp: add an explicit reference from a mctp_sk_key to sock")Signed-off-by Jeremy Kerr <[email protected]>
Hi Jeremy!
This patch is good to be applied, right?
It got marked Not Applicable in patchwork, not sure why.
Jeremy Kerr
maintainerHi Jakub,
Quoted 1 line
This patch is good to be applied, right?
Yep, all good on my side!
Quoted 1 line
It got marked Not Applicable in patchwork, not sure why.
Also not sure what happened there - I hadn't set that myself, at least!
Cheers,
Jeremy
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 Thu, 15 Feb 2024 15:53:08 +0800 you wrote:
We may hold an extra reference on a socket if a tag allocation fails: we optimistically allocate the
sk_key, and take a ref there, but do not drop if we end up not using the allocated key.Ensure we're dropping the sock on this failure by doing a proper unref rather than directly kfree()ing.
[...]
Here is the summary with links:
- [net] net: mctp: put sock on tag allocation failure
https://git.kernel.org/netdev/net/c/9990889be142
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html