diff options
author | Jeremy Kerr <jk@codeconstruct.com.au> | 2024-02-15 15:53:08 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-03-01 13:35:09 +0100 |
commit | 18a3d49aee3173fa0152a044ce607e6e01632444 (patch) | |
tree | 5085981d8048cd4c3ac724a6f4d57c2dd74d0a52 /net/mctp | |
parent | 73a7cdb487797f1b84822663c0fa3409bfb93b8a (diff) | |
download | linux-stable-18a3d49aee3173fa0152a044ce607e6e01632444.tar.gz linux-stable-18a3d49aee3173fa0152a044ce607e6e01632444.tar.bz2 linux-stable-18a3d49aee3173fa0152a044ce607e6e01632444.zip |
net: mctp: put sock on tag allocation failure
[ Upstream commit 9990889be14288d4f1743e4768222d5032a79c27 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/mctp')
-rw-r--r-- | net/mctp/route.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/mctp/route.c b/net/mctp/route.c index 7a47a58aa54b..6218dcd07e18 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); } |