Only call folio_size() in fuse_copy_folio() after checking that the folio is not null. Signed-off-by: Joanne Koong <joannelkoong@xxxxxxxxx> Fixes: f008a4390bde (“fuse: support copying large folios”) --- This was pointed out by Dan in this bug report: https://lore.kernel.org/linux-fsdevel/aDCbR9VpB3ojnM7q@stanley.mountain/T/#u It'd be great if this patch could be folded into the original f008a4390bde commit in the for-next tree. Thanks, Joanne --- fs/fuse/dev.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index fa038327f7a7..e80cd8f2c049 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1098,10 +1098,13 @@ static int fuse_copy_folio(struct fuse_copy_state *cs, struct folio **foliop, { int err; struct folio *folio = *foliop; - size_t size = folio_size(folio); + size_t size; - if (folio && zeroing && count < size) - folio_zero_range(folio, 0, size); + if (folio) { + size = folio_size(folio); + if (zeroing && count < size) + folio_zero_range(folio, 0, size); + } while (count) { if (cs->write && cs->pipebufs && folio) { @@ -1118,7 +1121,7 @@ static int fuse_copy_folio(struct fuse_copy_state *cs, struct folio **foliop, } } else if (!cs->len) { if (cs->move_folios && folio && - offset == 0 && count == folio_size(folio)) { + offset == 0 && count == size) { err = fuse_try_move_folio(cs, foliop); if (err <= 0) return err; -- 2.47.1