[PATCH] f2fs: handle NULL kiocb in write_begin

From: Wenjie Qi

Date: Sat Sep 05 2026 - 09:33:00 EST


From: Wenjie Qi <qiwenjie@xxxxxxxxxx>

The address-space write_begin callback is also used by internal callers
that pass a NULL kiocb, including page_symlink().

Check iocb before propagating IOCB_DONTCACHE into the F2FS-specific folio
lookup flags.

Fixes: cd5bc4fbb900 ("f2fs: enable buffered RWF_DONTCACHE")
Reported-by: syzbot+cid5582b8164122eda@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://ci.syzbot.org/series/cbb9ded8-1388-4a7b-bfa7-44082b04025b
Signed-off-by: Wenjie Qi <qiwenjie@xxxxxxxxxx>
---
#syz test

fs/f2fs/data.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 6e816c9349a..63625ab3f1e 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3890,7 +3890,7 @@ static int f2fs_write_begin(const struct kiocb *iocb,
block_t blkaddr = NULL_ADDR;
int err = 0;

- if (iocb->ki_flags & IOCB_DONTCACHE)
+ if (iocb && iocb->ki_flags & IOCB_DONTCACHE)
fgp_flags |= FGP_DONTCACHE;

trace_f2fs_write_begin(inode, pos, len);
--
2.43.0