NFS: Read unlock folio on nfs_page_create_from_folio() error
authorBenjamin Coddington <bcodding@redhat.com>
Thu, 7 Mar 2024 14:41:18 +0000 (09:41 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Sat, 9 Mar 2024 14:14:51 +0000 (09:14 -0500)
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>
Acked-by: Dave Wysochanski <dwysocha@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/read.c

index 7dc21a48e3e7b6a0b86f06148163450e79564f82..a142287d86f68ed411dce6f9c410e41948c570b2 100644 (file)
@@ -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;
        }