public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfs: Add missing release on error in nfs_lock_and_join_requests()
@ 2025-04-02 11:02 Dan Carpenter
  2025-04-02 13:56 ` Trond Myklebust
  2025-04-03  4:35 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-04-02 11:02 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Trond Myklebust, Anna Schumaker, Sagi Grimberg, linux-nfs,
	linux-kernel, kernel-janitors

Call nfs_release_request() on this error path before returning.

Fixes: c3f2235782c3 ("nfs: fold nfs_folio_find_and_lock_request into nfs_lock_and_join_requests")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
From static analysis and untested.  Pretty sure it's correct, though.  ;)

 fs/nfs/write.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index aa3d8bea3ec0..23df8b214474 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -579,8 +579,10 @@ static struct nfs_page *nfs_lock_and_join_requests(struct folio *folio)
 
 	while (!nfs_lock_request(head)) {
 		ret = nfs_wait_on_request(head);
-		if (ret < 0)
+		if (ret < 0) {
+			nfs_release_request(head);
 			return ERR_PTR(ret);
+		}
 	}
 
 	/* Ensure that nobody removed the request before we locked it */
-- 
2.47.2


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

* Re: [PATCH] nfs: Add missing release on error in nfs_lock_and_join_requests()
  2025-04-02 11:02 [PATCH] nfs: Add missing release on error in nfs_lock_and_join_requests() Dan Carpenter
@ 2025-04-02 13:56 ` Trond Myklebust
  2025-04-03  4:35 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Trond Myklebust @ 2025-04-02 13:56 UTC (permalink / raw)
  To: hch@lst.de, dan.carpenter@linaro.org
  Cc: anna@kernel.org, linux-nfs@vger.kernel.org, sagi@grimberg.me,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org

On Wed, 2025-04-02 at 14:02 +0300, Dan Carpenter wrote:
> Call nfs_release_request() on this error path before returning.
> 
> Fixes: c3f2235782c3 ("nfs: fold nfs_folio_find_and_lock_request into
> nfs_lock_and_join_requests")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> From static analysis and untested.  Pretty sure it's correct,
> though.  ;)
> 
>  fs/nfs/write.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfs/write.c b/fs/nfs/write.c
> index aa3d8bea3ec0..23df8b214474 100644
> --- a/fs/nfs/write.c
> +++ b/fs/nfs/write.c
> @@ -579,8 +579,10 @@ static struct nfs_page
> *nfs_lock_and_join_requests(struct folio *folio)
>  
>  	while (!nfs_lock_request(head)) {
>  		ret = nfs_wait_on_request(head);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			nfs_release_request(head);
>  			return ERR_PTR(ret);
> +		}
>  	}
>  
>  	/* Ensure that nobody removed the request before we locked
> it */

Yep, that's a slam dunk. Thanks for spotting it!

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



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

* Re: [PATCH] nfs: Add missing release on error in nfs_lock_and_join_requests()
  2025-04-02 11:02 [PATCH] nfs: Add missing release on error in nfs_lock_and_join_requests() Dan Carpenter
  2025-04-02 13:56 ` Trond Myklebust
@ 2025-04-03  4:35 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2025-04-03  4:35 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Christoph Hellwig, Trond Myklebust, Anna Schumaker, Sagi Grimberg,
	linux-nfs, linux-kernel, kernel-janitors

On Wed, Apr 02, 2025 at 02:02:40PM +0300, Dan Carpenter wrote:
> Call nfs_release_request() on this error path before returning.
> 
> Fixes: c3f2235782c3 ("nfs: fold nfs_folio_find_and_lock_request into nfs_lock_and_join_requests")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


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

end of thread, other threads:[~2025-04-03  4:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-02 11:02 [PATCH] nfs: Add missing release on error in nfs_lock_and_join_requests() Dan Carpenter
2025-04-02 13:56 ` Trond Myklebust
2025-04-03  4:35 ` Christoph Hellwig

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