]> git.baikalelectronics.ru Git - kernel.git/commit
zonefs: fix page reference and BIO leak
authorDamien Le Moal <damien.lemoal@wdc.com>
Wed, 9 Dec 2020 11:16:10 +0000 (20:16 +0900)
committerDamien Le Moal <damien.lemoal@wdc.com>
Thu, 10 Dec 2020 06:14:19 +0000 (15:14 +0900)
commit8beb44928ecf6c7dcbf88c31444ef7da85dce699
treedd1abc26e443eb6209bce93c4a57aeb229eb7dd4
parentbe9919d50c73e382981878ad564e3064ed8e1c57
zonefs: fix page reference and BIO leak

In zonefs_file_dio_append(), the pages obtained using
bio_iov_iter_get_pages() are not released on completion of the
REQ_OP_APPEND BIO, nor when bio_iov_iter_get_pages() fails.
Furthermore, a call to bio_put() is missing when
bio_iov_iter_get_pages() fails.

Fix these resource leaks by adding BIO resource release code (bio_put()i
and bio_release_pages()) at the end of the function after the BIO
execution and add a jump to this resource cleanup code in case of
bio_iov_iter_get_pages() failure.

While at it, also fix the call to task_io_account_write() to be passed
the correct BIO size instead of bio_iov_iter_get_pages() return value.

Reported-by: Christoph Hellwig <hch@lst.de>
Fixes: 5544a7d3bf84 ("zonefs: use REQ_OP_ZONE_APPEND for sync DIO")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/zonefs/super.c