diff mbox series

NFS: Read unlock folio on nfs_page_create_from_folio() error

Message ID 810bc21335858754c1a3fbee0a3c94de001f4c3f.1709659767.git.bcodding@redhat.com (mailing list archive)
State New
Headers show
Series NFS: Read unlock folio on nfs_page_create_from_folio() error | expand

Commit Message

Benjamin Coddington March 5, 2024, 5:30 p.m. UTC
The netfs conversion lost a folio_unlock() for the case where
nfs_page_create_from_folio() returns an error (usually -ENOMEM).  Restore
it.

Reported-by: David Jeffery <djeffery@redhat.com>
Cc: <stable@vger.kernel.org> # 6.4+
Fixes: 000dbe0bec05 ("NFS: Convert buffered read paths to use netfs when fscache is enabled")
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/read.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Wysochanski March 5, 2024, 6 p.m. UTC | #1
On Tue, Mar 5, 2024 at 12:30 PM Benjamin Coddington <bcodding@redhat.com> wrote:
>
> The netfs conversion lost a folio_unlock() for the case where
> nfs_page_create_from_folio() returns an error (usually -ENOMEM).  Restore
> it.
>
> Reported-by: David Jeffery <djeffery@redhat.com>
> Cc: <stable@vger.kernel.org> # 6.4+
> Fixes: 000dbe0bec05 ("NFS: Convert buffered read paths to use netfs when fscache is enabled")
> Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
> ---
>  fs/nfs/read.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/fs/nfs/read.c b/fs/nfs/read.c
> index 7dc21a48e3e7..a142287d86f6 100644
> --- a/fs/nfs/read.c
> +++ b/fs/nfs/read.c
> @@ -305,6 +305,8 @@ int nfs_read_add_folio(struct nfs_pageio_descriptor *pgio,
>         new = nfs_page_create_from_folio(ctx, folio, 0, aligned_len);
>         if (IS_ERR(new)) {
>                 error = PTR_ERR(new);
> +               if (nfs_netfs_folio_unlock(folio))
> +                       folio_unlock(folio);
>                 goto out;
>         }
>
> --
> 2.43.0
>


Acked-by: Dave Wysochanski <dwysocha@redhat.com>
diff mbox series

Patch

diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 7dc21a48e3e7..a142287d86f6 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -305,6 +305,8 @@  int nfs_read_add_folio(struct nfs_pageio_descriptor *pgio,
 	new = nfs_page_create_from_folio(ctx, folio, 0, aligned_len);
 	if (IS_ERR(new)) {
 		error = PTR_ERR(new);
+		if (nfs_netfs_folio_unlock(folio))
+			folio_unlock(folio);
 		goto out;
 	}