diff mbox series

[1/2] rxrpc: Fix rxrpc_peer leak in rxrpc_look_up_bundle()

Message ID 163776465314.1844202.9057900281265187616.stgit@warthog.procyon.org.uk (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series [1/2] rxrpc: Fix rxrpc_peer leak in rxrpc_look_up_bundle() | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: davem@davemloft.net
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 32 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

David Howells Nov. 24, 2021, 2:37 p.m. UTC
From: Eiichi Tsukata <eiichi.tsukata@nutanix.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@nutanix.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.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(-)

Comments

Jakub Kicinski Nov. 26, 2021, 3:27 a.m. UTC | #1
On Wed, 24 Nov 2021 14:37:33 +0000 David Howells wrote:
> From: Eiichi Tsukata <eiichi.tsukata@nutanix.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@nutanix.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Marc Dionne <marc.dionne@auristor.com>
> cc: linux-afs@lists.infradead.org
> Link: https://lore.kernel.org/r/20211121041608.133740-1-eiichi.tsukata@nutanix.com/ # v1

Are these supposed to go to net? They are addressed To: the author.
David Howells Nov. 26, 2021, 8:05 a.m. UTC | #2
Jakub Kicinski <kuba@kernel.org> wrote:

> Are these supposed to go to net? They are addressed To: the author.

I'm hoping the author rechecks/reviews them.  I commented on his original
submission that I thought they could be done slightly differently.

David
Eiichi Tsukata Nov. 26, 2021, 8:34 a.m. UTC | #3
> On Nov 26, 2021, at 17:05, David Howells <dhowells@redhat.com> wrote:
> 
> Jakub Kicinski <kuba@kernel.org> wrote:
> 
>> Are these supposed to go to net? They are addressed To: the author.
> 
> I'm hoping the author rechecks/reviews them.  I commented on his original
> submission that I thought they could be done slightly differently.
> 

Thanks, I’ve tested them with my environment. Looks good.

Eiichi
Marc Dionne Nov. 26, 2021, 1:12 p.m. UTC | #4
On Wed, Nov 24, 2021 at 10:37 AM David Howells <dhowells@redhat.com> wrote:
>
> From: Eiichi Tsukata <eiichi.tsukata@nutanix.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@nutanix.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Marc Dionne <marc.dionne@auristor.com>
> cc: linux-afs@lists.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@auristor.com>

Marc
David Howells Nov. 29, 2021, 3:40 p.m. UTC | #5
Eiichi Tsukata <eiichi.tsukata@nutanix.com> wrote:

> Thanks, I’ve tested them with my environment. Looks good.

Thanks.

David
David Howells Nov. 29, 2021, 3:53 p.m. UTC | #6
Hi Jakub,

> Are these supposed to go to net? They are addressed To: the author.

I've posted a new set to netdev that has the Acks from Marc added for you to
pick up.

David
diff mbox series

Patch

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);