]> git.hungrycats.org Git - linux/commit
net: mctp: put sock on tag allocation failure
authorJeremy Kerr <jk@codeconstruct.com.au>
Thu, 15 Feb 2024 07:53:08 +0000 (15:53 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Mar 2024 12:26:38 +0000 (13:26 +0100)
commitc22ad76cfc43a2c7923de1a9acc0d05b9fa2c63c
tree919acf27fd8c183b9912b63ccb232f858ca6b409
parentea33b816691255d1d5eeb7f5a02f2acf6a556393
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>
net/mctp/route.c