]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ext2: fix ignored return value of generic_write_sync()
authorDanila Chernetsov <listdansp@mail.ru>
Sat, 30 May 2026 12:23:11 +0000 (12:23 +0000)
committerJan Kara <jack@suse.cz>
Tue, 2 Jun 2026 08:56:16 +0000 (10:56 +0200)
commita4659be0bc7cb1856ffb15b67f903229ae8891ec
treeae0c34b8d8efe69b0aafffefab7476743cb5e6cf
parentf6fce9f17d9cfde8a88beda1527600d6daacc49b
ext2: fix ignored return value of generic_write_sync()

Fix ext2_dio_write_iter() to propagate the error returned by
generic_write_sync() instead of silently discarding it, which could
cause write(2) to return success to userspace on O_SYNC/O_DSYNC files
even when the sync failed.

The correct pattern, already used in ext2_dax_write_iter() in the same
file and in ext4, xfs, f2fs among others, is:
    if (ret > 0)
        ret = generic_write_sync(iocb, ret);

Found by Linux Verification Center (linuxtesting.org) with SVACE.

[JK: Reflect also filemap_write_and_wait() return value]

Fixes: fb5de4358e1a ("ext2: Move direct-io to use iomap")
Signed-off-by: Danila Chernetsov <listdansp@mail.ru>
Link: https://patch.msgid.link/20260530122311.136803-1-listdansp@mail.ru
Signed-off-by: Jan Kara <jack@suse.cz>
fs/ext2/file.c