diff mbox series

[net,2/2] rxrpc: Fix rxrpc_local leak in rxrpc_lookup_peer()

Message ID 20211121041608.133740-2-eiichi.tsukata@nutanix.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series [net,1/2] rxrpc: Fix rxrpc_peer leak in rxrpc_look_up_bundle() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
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 success CCed 6 of 6 maintainers
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, 14 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Eiichi Tsukata Nov. 21, 2021, 4:16 a.m. UTC
Need to call rxrpc_put_local() for peer candidate before kfree() as it
holds a ref to rxrpc_local.

Fixes: 9ebeddef58c4 ("rxrpc: rxrpc_peer needs to hold a ref on the rxrpc_local record")
Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
---
 net/rxrpc/peer_object.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Marc Dionne Nov. 23, 2021, 2:11 p.m. UTC | #1
On Sun, Nov 21, 2021 at 12:17 AM Eiichi Tsukata
<eiichi.tsukata@nutanix.com> wrote:
>
> Need to call rxrpc_put_local() for peer candidate before kfree() as it
> holds a ref to rxrpc_local.
>
> Fixes: 9ebeddef58c4 ("rxrpc: rxrpc_peer needs to hold a ref on the rxrpc_local record")
> Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
> ---
>  net/rxrpc/peer_object.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/rxrpc/peer_object.c b/net/rxrpc/peer_object.c
> index 68396d052052..431b62bc1da2 100644
> --- a/net/rxrpc/peer_object.c
> +++ b/net/rxrpc/peer_object.c
> @@ -364,10 +364,12 @@ struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_sock *rx,
>
>                 spin_unlock_bh(&rxnet->peer_hash_lock);
>
> -               if (peer)
> +               if (peer) {
> +                       rxrpc_put_local(candidate->local);
>                         kfree(candidate);
> -               else
> +               } else {
>                         peer = candidate;
> +               }
>         }
>
>         _net("PEER %d {%pISp}", peer->debug_id, &peer->srx.transport);
> --
> 2.33.1

Reviewed-by: Marc Dionne <marc.dionne@auristor.com>

Marc
diff mbox series

Patch

diff --git a/net/rxrpc/peer_object.c b/net/rxrpc/peer_object.c
index 68396d052052..431b62bc1da2 100644
--- a/net/rxrpc/peer_object.c
+++ b/net/rxrpc/peer_object.c
@@ -364,10 +364,12 @@  struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_sock *rx,
 
 		spin_unlock_bh(&rxnet->peer_hash_lock);
 
-		if (peer)
+		if (peer) {
+			rxrpc_put_local(candidate->local);
 			kfree(candidate);
-		else
+		} else {
 			peer = candidate;
+		}
 	}
 
 	_net("PEER %d {%pISp}", peer->debug_id, &peer->srx.transport);