aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@codeconstruct.com.au>2024-02-15 15:53:08 +0800
committerJakub Kicinski <kuba@kernel.org>2024-02-21 17:01:54 -0800
commit9990889be14288d4f1743e4768222d5032a79c27 (patch)
tree502a80a13e71457ed46f1d21e5a3eb396b9a6b99
parentf76d5f65805695afc65e4c265bd119b7e2e88442 (diff)
downloadlinux-9990889be14288d4f1743e4768222d5032a79c27.tar.gz
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. Fixes: de8a6b15d965 ("net: mctp: add an explicit reference from a mctp_sk_key to sock") Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/r/ce9b61e44d1cdae7797be0c5e3141baf582d23a0.1707983487.git.jk@codeconstruct.com.au Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Notes
Fixes: de8a6b15d965 ("net: mctp: add an explicit reference from a mctp_sk_key to sock") # v6.2-rc6 Fixes-stable: d0cdcc3da926 ("net: mctp: add an explicit reference from a mctp_sk_key to sock") # v6.1.9 Stable: 18a3d49aee31 # v6.6.19 Stable: c22ad76cfc43 # v6.1.80 Lore: https://lore.kernel.org/r/20240227131616.215598146@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/20240227131634.559363383@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/20240227131641.102198188@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/ce9b61e44d1cdae7797be0c5e3141baf582d23a0.1707983487.git.jk@codeconstruct.com.au # netdev
-rw-r--r--net/mctp/route.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/mctp/route.c b/net/mctp/route.c
index 7a47a58aa54b44..6218dcd07e184e 100644
--- a/net/mctp/route.c
+++ b/net/mctp/route.c
@@ -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);
}