gfs2: Fix gfs2_file_buffered_write endless loop workaround
authorAndreas Gruenbacher <agruenba@redhat.com>
Thu, 17 Mar 2022 13:47:24 +0000 (14:47 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Jul 2022 14:34:59 +0000 (16:34 +0200)
[ Upstream commit 46f3e0421ccb5474b5c006b0089b9dfd42534bb6 ]

Since commit 554c577cee95b, gfs2_file_buffered_write() can accidentally
return a truncated iov_iter, which might confuse callers.  Fix that.

Fixes: 554c577cee95b ("gfs2: Prevent endless loops in gfs2_file_buffered_write")
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/gfs2/file.c

index 60390f9..e93185d 100644 (file)
@@ -1086,6 +1086,7 @@ out_uninit:
        gfs2_holder_uninit(gh);
        if (statfs_gh)
                kfree(statfs_gh);
+       from->count = orig_count - read;
        return read ? read : ret;
 }