Skip to content

Commit

Permalink
net: mctp: put sock on tag allocation failure
Browse files Browse the repository at this point in the history
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: de8a6b1 ("net: mctp: add an explicit reference from a mctp_sk_key to sock")
Signed-off-by: Jeremy Kerr <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Link: https://lore.kernel.org/r/ce9b61e44d1cdae7797be0c5e3141baf582d23a0.1707983487.git.jk@codeconstruct.com.au
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
jk-ozlabs authored and kuba-moo committed Feb 22, 2024
1 parent f76d5f6 commit 9990889
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/mctp/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 9990889

Please sign in to comment.