summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorJiangshan Yi <yijiangshan@kylinos.cn>2026-07-02 09:50:14 +0800
committerTrond Myklebust <trond.myklebust@hammerspace.com>2026-08-17 09:02:07 -0700
commit59075fb8b7887b4149e73e3d5aee2ceeeb87d287 (patch)
tree22608637609e1374053c81747bad96297b3711cb /include/linux
parentb4dd7f81592287c9b4070e6669732d8770269303 (diff)
NFS: fix folio dereference before NULL check in nfs_inode_remove_request()
nfs_inode_remove_request() obtains the folio for the head request via nfs_page_to_folio(), which returns NULL when the PG_FOLIO flag is not set on req->wb_head. The presence of the "if (likely(folio))" check shows the code already assumes folio can be NULL. However, folio was dereferenced before that check: folio = nfs_page_to_folio(req->wb_head); mapping = folio->mapping; /* deref */ spin_lock(&mapping->i_private_lock); if (likely(folio)) { /* too late */ folio->mapping is read (and mapping->i_private_lock is taken, and folio_end_dropbehind(folio) is called outside the check) before folio is validated, so a NULL folio would crash before the guard is ever reached, rendering the check useless. Move the folio->mapping read, the i_private_lock section and the folio_end_dropbehind() call inside the "if (likely(folio))" block so the folio is only dereferenced after it has been confirmed non-NULL. The behaviour is unchanged when folio is non-NULL. Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions