]> git.baikalelectronics.ru Git - kernel.git/commit
block: fix leaking page ref on truncated direct io
authorKeith Busch <kbusch@kernel.org>
Tue, 12 Jul 2022 15:32:56 +0000 (08:32 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 3 Aug 2022 03:08:54 +0000 (21:08 -0600)
commit3ba20086004f8741ccbb8667ebbe1cf5b2b711fd
tree8cf90aab52270f2e71cb3b961c3c32d51d66ebf1
parente5657bd090788dfa7391165c6842f9a2056ae208
block: fix leaking page ref on truncated direct io

The size being added to a bio from an iov is aligned to a block size
after the pages were gotten. If the new aligned size truncates the last
page, its reference was being leaked. Ensure all pages that were not
added to the bio have their reference released.

Since this essentially requires doing the same that bio_put_pages(), and
there was only one caller for that function, this patch makes the
put_page() loop common for everyone.

Fixes: 23d598b5a60e0 ("block: relax direct io memory alignment")
Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Link: https://lore.kernel.org/r/20220712153256.2202024-3-kbusch@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c