All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ceph: Fix error handling in fill_readdir_cache()
@ 2025-03-04 15:48 Matthew Wilcox (Oracle)
  2025-03-04 18:41 ` Viacheslav Dubeyko
  2025-03-05 10:48 ` Christian Brauner
  0 siblings, 2 replies; 5+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-03-04 15:48 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Matthew Wilcox (Oracle), linux-fsdevel, ceph-devel, Dan Carpenter,
	Viacheslav Dubeyko

__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: baff9740bc8f ("ceph: Convert ceph_readdir_cache_control to store a folio")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
---
 fs/ceph/inode.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index c15970fa240f..6ac2bd555e86 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1870,9 +1870,12 @@ static int fill_readdir_cache(struct inode *dir, struct dentry *dn,
 
 		ctl->folio = __filemap_get_folio(&dir->i_data, pgoff,
 				fgf, mapping_gfp_mask(&dir->i_data));
-		if (!ctl->folio) {
+		if (IS_ERR(ctl->folio)) {
+			int err = PTR_ERR(ctl->folio);
+
+			ctl->folio = NULL;
 			ctl->index = -1;
-			return idx == 0 ? -ENOMEM : 0;
+			return idx == 0 ? err : 0;
 		}
 		/* reading/filling the cache are serialized by
 		 * i_rwsem, no need to use folio lock */
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-03-05 10:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-04 15:48 [PATCH] ceph: Fix error handling in fill_readdir_cache() Matthew Wilcox (Oracle)
2025-03-04 18:41 ` Viacheslav Dubeyko
2025-03-05  4:29   ` Matthew Wilcox
2025-03-05  8:18     ` Dan Carpenter
2025-03-05 10:48 ` Christian Brauner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.