AF_RXRPC fixes
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEqG5UsNXhtOCrfGQP+7dXa6fLC2sFAmGk9MIACgkQ+7dXa6fL C2sFUw/9EulPVJSzUywa6Jf13BqWCqciuMoo+NrNlTFY7P0CnurloqOl+6hJ+hYI cKr4JaClzOR/LT8DaJHYp+uyB0cn5U/udEDr2iekxvh16B/GDDRPWDDIvm9mzczw jVqzZHH54Jl6s+fnfkIhkLZA6rTuH4kFtsEb1S0VBXIJC1zv4O79Ba15nxkGPQoQ GfJzZqLTUOMmWPoiTuKTJmPhvCPHEzIGduKzU2hRgjrDJdk695BGdwFK1cs6/BcA n0aEVnYmndnaJ3MyLjxzROi1D6MFfHs8+a4vKTD13kcWQRT8kPE51/KKhMvUELHn HJsVXqFeip2FyQFqRlmNfRgfvhC+SWV9kceP0G6pZIoLAXlEMGkmhmB+BWZtnY6U yXaOJlwchNEP83f2KWUBkX4dV9Zx8mdy5UUQBTSQbMwFxSgZ5FfOyCkf98xx03DS LTqV9ZciJ+Z6QbDscYIrnJV2WvWTJeyUB5lsI8W3lAXXugu28WHL+lorhEKIIJWG jdmxO4sEa29tdE7FVngQ3RLcNJETcJCKpMypNaAhWOCPlfnW7t0FpkcAoza7t1yy DGQaGkR7zC1sZ5hr31YvWBhaZT8IjlAePOg/1GfpUnyL9122jsAqR9dz0xgPGnf6 fK0BLMcfnuYObtJdSEOAMqnx2qkRKTU9qrT2vXNWd/bApFTY4E0= =q6GF -----END PGP SIGNATURE----- Merge tag 'rxrpc-fixes-20211129' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs David Howells says: ==================== rxrpc: Leak fixes Here are a couple of fixes for leaks in AF_RXRPC: (1) Fix a leak of rxrpc_peer structs in rxrpc_look_up_bundle(). (2) Fix a leak of rxrpc_local structs in rxrpc_lookup_peer(). * tag 'rxrpc-fixes-20211129' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: rxrpc: Fix rxrpc_local leak in rxrpc_lookup_peer() rxrpc: Fix rxrpc_peer leak in rxrpc_look_up_bundle() ==================== Link: https://lore.kernel.org/r/163820097905.226370.17234085194655347888.stgit@warthog.procyon.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
5fdc2333e6
@ -135,16 +135,20 @@ struct rxrpc_bundle *rxrpc_get_bundle(struct rxrpc_bundle *bundle)
|
||||
return bundle;
|
||||
}
|
||||
|
||||
static void rxrpc_free_bundle(struct rxrpc_bundle *bundle)
|
||||
{
|
||||
rxrpc_put_peer(bundle->params.peer);
|
||||
kfree(bundle);
|
||||
}
|
||||
|
||||
void rxrpc_put_bundle(struct rxrpc_bundle *bundle)
|
||||
{
|
||||
unsigned int d = bundle->debug_id;
|
||||
unsigned int u = atomic_dec_return(&bundle->usage);
|
||||
|
||||
_debug("PUT B=%x %u", d, u);
|
||||
if (u == 0) {
|
||||
rxrpc_put_peer(bundle->params.peer);
|
||||
kfree(bundle);
|
||||
}
|
||||
if (u == 0)
|
||||
rxrpc_free_bundle(bundle);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -328,7 +332,7 @@ static struct rxrpc_bundle *rxrpc_look_up_bundle(struct rxrpc_conn_parameters *c
|
||||
return candidate;
|
||||
|
||||
found_bundle_free:
|
||||
kfree(candidate);
|
||||
rxrpc_free_bundle(candidate);
|
||||
found_bundle:
|
||||
rxrpc_get_bundle(bundle);
|
||||
spin_unlock(&local->client_bundles_lock);
|
||||
|
@ -299,6 +299,12 @@ static struct rxrpc_peer *rxrpc_create_peer(struct rxrpc_sock *rx,
|
||||
return peer;
|
||||
}
|
||||
|
||||
static void rxrpc_free_peer(struct rxrpc_peer *peer)
|
||||
{
|
||||
rxrpc_put_local(peer->local);
|
||||
kfree_rcu(peer, rcu);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up a new incoming peer. There shouldn't be any other matching peers
|
||||
* since we've already done a search in the list from the non-reentrant context
|
||||
@ -365,7 +371,7 @@ struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_sock *rx,
|
||||
spin_unlock_bh(&rxnet->peer_hash_lock);
|
||||
|
||||
if (peer)
|
||||
kfree(candidate);
|
||||
rxrpc_free_peer(candidate);
|
||||
else
|
||||
peer = candidate;
|
||||
}
|
||||
@ -420,8 +426,7 @@ static void __rxrpc_put_peer(struct rxrpc_peer *peer)
|
||||
list_del_init(&peer->keepalive_link);
|
||||
spin_unlock_bh(&rxnet->peer_hash_lock);
|
||||
|
||||
rxrpc_put_local(peer->local);
|
||||
kfree_rcu(peer, rcu);
|
||||
rxrpc_free_peer(peer);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -457,8 +462,7 @@ void rxrpc_put_peer_locked(struct rxrpc_peer *peer)
|
||||
if (n == 0) {
|
||||
hash_del_rcu(&peer->hash_link);
|
||||
list_del_init(&peer->keepalive_link);
|
||||
rxrpc_put_local(peer->local);
|
||||
kfree_rcu(peer, rcu);
|
||||
rxrpc_free_peer(peer);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user