]> git.baikalelectronics.ru Git - kernel.git/commit
mctp: Avoid leak of mctp_sk_key
authorMatt Johnston <matt@codeconstruct.com.au>
Thu, 14 Oct 2021 08:10:50 +0000 (16:10 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 15 Oct 2021 10:22:08 +0000 (11:22 +0100)
commit9c68e36e540c78b852a9a3011c0c9cd39d042ddb
tree69a36266a237fb8f644c999888d9cf40abd3f450
parent1959b2f6b33571adc7112e7b39f5734aeab32610
mctp: Avoid leak of mctp_sk_key

mctp_key_alloc() returns a key already referenced.

The mctp_route_input() path receives a packet for a bind socket and
allocates a key. It passes the key to mctp_key_add() which takes a
refcount and adds the key to lists. mctp_route_input() should then
release its own refcount when setting the key pointer to NULL.

In the mctp_alloc_local_tag() path (for mctp_local_output()) we
similarly need to unref the key before returning (mctp_reserve_tag()
takes a refcount and adds the key to lists).

Fixes: c88d6fe021f9 ("mctp: locking, lifetime and validity changes for sk_keys")
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mctp/route.c