]> git.hungrycats.org Git - linux/commit
Btrfs: fix eb memory leak due to readpage failure
authorLiu Bo <bo.li.liu@oracle.com>
Mon, 11 Jul 2016 17:39:07 +0000 (10:39 -0700)
committerZygo Blaxell <zblaxell@waya.furryterror.org>
Wed, 17 Aug 2016 02:23:54 +0000 (22:23 -0400)
commit57e8eacc7cf4d797c0a73f39396b0a56ccf2de77
tree26169e60f58a51e67c049e5ff41c7ae848da2c9e
parent6ebb0d7bb4cb5d387dcdbd3cd1f1ecc38151f355
Btrfs: fix eb memory leak due to readpage failure

eb->io_pages is set in read_extent_buffer_pages().

In case of readpage failure, for pages that have been added to bio,
it calls bio_endio and later readpage_io_failed_hook() does the work.

When this eb's page (couldn't be the 1st page) fails to add itself to bio
due to failure in merge_bio(), it cannot decrease eb->io_pages via bio_endio,
 and ends up with a memory leak eventually.

This lets __do_readpage propagate errors to callers and adds the
 'atomic_dec(&eb->io_pages)'.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
(cherry picked from commit baf863b9c29617cc9eaf24e039f58846e700db48)
fs/btrfs/extent_io.c