[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAB9dFdtVr0cOxMe-L4E0NQLi1__R8a=7j7zXapzYmwRyCnRgZg@mail.gmail.com>
Date: Fri, 26 Nov 2021 09:12:55 -0400
From: Marc Dionne <marc.dionne@...istor.com>
To: David Howells <dhowells@...hat.com>
Cc: Eiichi Tsukata <eiichi.tsukata@...anix.com>,
linux-afs@...ts.infradead.org, Jakub Kicinski <kuba@...nel.org>,
netdev <netdev@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] rxrpc: Fix rxrpc_peer leak in rxrpc_look_up_bundle()
On Wed, Nov 24, 2021 at 10:37 AM David Howells <dhowells@...hat.com> wrote:
>
> From: Eiichi Tsukata <eiichi.tsukata@...anix.com>
>
> Need to call rxrpc_put_peer() for bundle candidate before kfree() as it
> holds a ref to rxrpc_peer.
>
> [DH: v2: Changed to abstract out the bundle freeing code into a function]
>
> Fixes: 245500d853e9 ("rxrpc: Rewrite the client connection manager")
> Signed-off-by: Eiichi Tsukata <eiichi.tsukata@...anix.com>
> Signed-off-by: David Howells <dhowells@...hat.com>
> cc: Marc Dionne <marc.dionne@...istor.com>
> cc: linux-afs@...ts.infradead.org
> Link: https://lore.kernel.org/r/20211121041608.133740-1-eiichi.tsukata@nutanix.com/ # v1
> ---
>
> net/rxrpc/conn_client.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/net/rxrpc/conn_client.c b/net/rxrpc/conn_client.c
> index dbea0bfee48e..8120138dac01 100644
> --- a/net/rxrpc/conn_client.c
> +++ b/net/rxrpc/conn_client.c
> @@ -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);
Reviewed-by: Marc Dionne <marc.dionne@...istor.com>
Marc
Powered by blists - more mailing lists