]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
afs: Fix afs_write_end() when called with copied == 0 [ver #3]
authorDavid Howells <dhowells@redhat.com>
Sat, 14 Nov 2020 17:27:57 +0000 (17:27 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Nov 2020 18:22:22 +0000 (19:22 +0100)
commit2ee7230e40d142c05843508c1f9227d46b15af48
tree3c31d7e42e3062d2746de858b266909351ca9a11
parent9e22b87afbc68524f7b76e1d88703e47023b3ba1
afs: Fix afs_write_end() when called with copied == 0 [ver #3]

[ Upstream commit 3ad216ee73abc554ed8f13f4f8b70845a7bef6da ]

When afs_write_end() is called with copied == 0, it tries to set the
dirty region, but there's no way to actually encode a 0-length region in
the encoding in page->private.

"0,0", for example, indicates a 1-byte region at offset 0.  The maths
miscalculates this and sets it incorrectly.

Fix it to just do nothing but unlock and put the page in this case.  We
don't actually need to mark the page dirty as nothing presumably
changed.

Fixes: 65dd2d6072d3 ("afs: Alter dirty range encoding in page->private")
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/afs/write.c