mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nfsd: Drop the client reference in client_states_open()
@ 2025-12-06  7:38 Haoxiang Li
  2025-12-06 14:37 ` Chuck Lever
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Haoxiang Li @ 2025-12-06  7:38 UTC (permalink / raw)
  To: chuck.lever, jlayton, neil, okorniev, Dai.Ngo, tom, bfields
  Cc: linux-nfs, linux-kernel, Haoxiang Li, stable

In error path, call drop_client() to drop the reference
obtained by get_nfsdfs_clp().

Fixes: a204f25e372d ("nfsd: create get_nfsdfs_clp helper")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
 fs/nfsd/nfs4state.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 8a6960500217..caa0756b6914 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3097,8 +3097,10 @@ static int client_states_open(struct inode *inode, struct file *file)
 		return -ENXIO;
 
 	ret = seq_open(file, &states_seq_ops);
-	if (ret)
+	if (ret) {
+		drop_client(clp);
 		return ret;
+	}
 	s = file->private_data;
 	s->private = clp;
 	return 0;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nfsd: Drop the client reference in client_states_open()
  2025-12-06  7:38 [PATCH] nfsd: Drop the client reference in client_states_open() Haoxiang Li
@ 2025-12-06 14:37 ` Chuck Lever
  2025-12-07  8:24   ` Haoxiang Li
  2025-12-06 18:43 ` Jeff Layton
  2025-12-07 16:16 ` Chuck Lever
  2 siblings, 1 reply; 5+ messages in thread
From: Chuck Lever @ 2025-12-06 14:37 UTC (permalink / raw)
  To: Haoxiang Li, Chuck Lever, Jeff Layton, NeilBrown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, bfields
  Cc: linux-nfs, linux-kernel, stable



On Sat, Dec 6, 2025, at 2:38 AM, Haoxiang Li wrote:
> In error path, call drop_client() to drop the reference
> obtained by get_nfsdfs_clp().
>
> Fixes: a204f25e372d ("nfsd: create get_nfsdfs_clp helper")

An argument could be made that 78599c42ae3c ("nfsd4: add file
to display list of client's opens") is where the reference
counting was first broken. Would you mind if I updated the
Fixes: tag when I apply this?


> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
> ---
>  fs/nfsd/nfs4state.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 8a6960500217..caa0756b6914 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -3097,8 +3097,10 @@ static int client_states_open(struct inode 
> *inode, struct file *file)
>  		return -ENXIO;
> 
>  	ret = seq_open(file, &states_seq_ops);
> -	if (ret)
> +	if (ret) {
> +		drop_client(clp);
>  		return ret;
> +	}
>  	s = file->private_data;
>  	s->private = clp;
>  	return 0;
> -- 
> 2.25.1

-- 
Chuck Lever

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nfsd: Drop the client reference in client_states_open()
  2025-12-06  7:38 [PATCH] nfsd: Drop the client reference in client_states_open() Haoxiang Li
  2025-12-06 14:37 ` Chuck Lever
@ 2025-12-06 18:43 ` Jeff Layton
  2025-12-07 16:16 ` Chuck Lever
  2 siblings, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2025-12-06 18:43 UTC (permalink / raw)
  To: Haoxiang Li, chuck.lever, neil, okorniev, Dai.Ngo, tom, bfields
  Cc: linux-nfs, linux-kernel, stable

On Sat, 2025-12-06 at 15:38 +0800, Haoxiang Li wrote:
> In error path, call drop_client() to drop the reference
> obtained by get_nfsdfs_clp().
> 
> Fixes: a204f25e372d ("nfsd: create get_nfsdfs_clp helper")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
> ---
>  fs/nfsd/nfs4state.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 8a6960500217..caa0756b6914 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -3097,8 +3097,10 @@ static int client_states_open(struct inode *inode, struct file *file)
>  		return -ENXIO;
>  
>  	ret = seq_open(file, &states_seq_ops);
> -	if (ret)
> +	if (ret) {
> +		drop_client(clp);
>  		return ret;
> +	}
>  	s = file->private_data;
>  	s->private = clp;
>  	return 0;

Nice catch.

Reviewed-by: Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nfsd: Drop the client reference in client_states_open()
  2025-12-06 14:37 ` Chuck Lever
@ 2025-12-07  8:24   ` Haoxiang Li
  0 siblings, 0 replies; 5+ messages in thread
From: Haoxiang Li @ 2025-12-07  8:24 UTC (permalink / raw)
  To: cel
  Cc: Dai.Ngo, bfields, chuck.lever, jlayton, lihaoxiang, linux-kernel,
	linux-nfs, neil, okorniev, stable, tom

Hi, Chuck!

Sat, 06 Dec 2025 09:37:44 -0500, Chuck Lever wrote:
> >
> On Sat, Dec 6, 2025, at 2:38 AM, Haoxiang Li wrote:
> > In error path, call drop_client() to drop the reference
> > obtained by get_nfsdfs_clp().
> >
> > Fixes: a204f25e372d ("nfsd: create get_nfsdfs_clp helper")

> An argument could be made that 78599c42ae3c ("nfsd4: add file
> to display list of client's opens") is where the reference
> counting was first broken. Would you mind if I updated the
> Fixes: tag when I apply this?

Thanks for pointing out the incorrect Fixes tag in the patch.
Please feel free to correct it.

-Haoxiang Li

> > Cc: stable@vger.kernel.org
> > Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
> > ---
> > fs/nfsd/nfs4state.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> > index 8a6960500217..caa0756b6914 100644
> > --- a/fs/nfsd/nfs4state.c
> > +++ b/fs/nfsd/nfs4state.c
> > @@ -3097,8 +3097,10 @@ static int client_states_open(struct inode 
> > *inode, struct file *file)
> >  	 	 return -ENXIO;
> >
> > 	 ret = seq_open(file, &states_seq_ops);
> > -	 if (ret)
> > +	 if (ret) {
> > +		 drop_client(clp);
> > 		 return ret;
> > +	 }
> > 	 s = file->private_data;
> > 	 s->private = clp;
> >  	 return 0;
> > -- 
> > 2.25.1

> -- 
> Chuck Lever


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nfsd: Drop the client reference in client_states_open()
  2025-12-06  7:38 [PATCH] nfsd: Drop the client reference in client_states_open() Haoxiang Li
  2025-12-06 14:37 ` Chuck Lever
  2025-12-06 18:43 ` Jeff Layton
@ 2025-12-07 16:16 ` Chuck Lever
  2 siblings, 0 replies; 5+ messages in thread
From: Chuck Lever @ 2025-12-07 16:16 UTC (permalink / raw)
  To: jlayton, neil, okorniev, Dai.Ngo, tom, bfields, Haoxiang Li
  Cc: Chuck Lever, linux-nfs, linux-kernel, stable

From: Chuck Lever <chuck.lever@oracle.com>

On Sat, 06 Dec 2025 15:38:42 +0800, Haoxiang Li wrote:
> In error path, call drop_client() to drop the reference
> obtained by get_nfsdfs_clp().
> 
> 

Applied to nfsd-testing, thanks!

[1/1] nfsd: Drop the client reference in client_states_open()
      commit: 88861b1c63861c7ee590e579b0b469c413154a6f

--
Chuck Lever


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-07 16:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-06  7:38 [PATCH] nfsd: Drop the client reference in client_states_open() Haoxiang Li
2025-12-06 14:37 ` Chuck Lever
2025-12-07  8:24   ` Haoxiang Li
2025-12-06 18:43 ` Jeff Layton
2025-12-07 16:16 ` Chuck Lever

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome