Skip to content

Commit efbdd92

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
ceph: Fix error handling in fill_readdir_cache()
__filemap_get_folio() returns an ERR_PTR, not NULL. There are extensive assumptions that ctl->folio is NULL, not an error pointer, so it seems better to fix this one place rather than change all the places which check ctl->folio. Fixes: baff974 ("ceph: Convert ceph_readdir_cache_control to store a folio") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: "Matthew Wilcox (Oracle)" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: Viacheslav Dubeyko <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent fff6974 commit efbdd92

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/ceph/inode.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,9 +1870,12 @@ static int fill_readdir_cache(struct inode *dir, struct dentry *dn,
18701870

18711871
ctl->folio = __filemap_get_folio(&dir->i_data, pgoff,
18721872
fgf, mapping_gfp_mask(&dir->i_data));
1873-
if (!ctl->folio) {
1873+
if (IS_ERR(ctl->folio)) {
1874+
int err = PTR_ERR(ctl->folio);
1875+
1876+
ctl->folio = NULL;
18741877
ctl->index = -1;
1875-
return idx == 0 ? -ENOMEM : 0;
1878+
return idx == 0 ? err : 0;
18761879
}
18771880
/* reading/filling the cache are serialized by
18781881
* i_rwsem, no need to use folio lock */

0 commit comments

Comments
 (0)