Skip to content

Commit 6a6d464

Browse files
scottmayhewamschuma-ntap
authored andcommitted
NFS: Fix potential oops in nfs_inode_remove_request()
Once a folio's private data has been cleared, it's possible for another process to clear the folio->mapping (e.g. via invalidate_complete_folio2 or evict_mapping_folio), so it wouldn't be safe to call nfs_page_to_inode() after that. Fixes: 0c493b5 ("NFS: Convert buffered writes to use folios") Signed-off-by: Scott Mayhew <[email protected]> Reviewed-by: Benjamin Coddington <[email protected]> Tested-by: Benjamin Coddington <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent f588d72 commit 6a6d464

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/nfs/write.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,8 @@ static void nfs_inode_add_request(struct nfs_page *req)
788788
*/
789789
static void nfs_inode_remove_request(struct nfs_page *req)
790790
{
791+
struct nfs_inode *nfsi = NFS_I(nfs_page_to_inode(req));
792+
791793
if (nfs_page_group_sync_on_bit(req, PG_REMOVE)) {
792794
struct folio *folio = nfs_page_to_folio(req->wb_head);
793795
struct address_space *mapping = folio_file_mapping(folio);
@@ -802,7 +804,7 @@ static void nfs_inode_remove_request(struct nfs_page *req)
802804
}
803805

804806
if (test_and_clear_bit(PG_INODE_REF, &req->wb_flags)) {
805-
atomic_long_dec(&NFS_I(nfs_page_to_inode(req))->nrequests);
807+
atomic_long_dec(&nfsi->nrequests);
806808
nfs_release_request(req);
807809
}
808810
}

0 commit comments

Comments
 (0)