btrfs: do not clean up repair bio if submit fails
authorJosef Bacik <josef@toxicpanda.com>
Fri, 18 Feb 2022 15:03:29 +0000 (10:03 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 14 Mar 2022 12:13:52 +0000 (13:13 +0100)
commit8cbc3001a3264d998d6b6db3e23f935c158abd4d
tree9770c317e743660f892e3a50fa3fddaa93752134
parent510671d2d83668b76c08baec5faa2319ceaffd62
btrfs: do not clean up repair bio if submit fails

The submit helper will always run bio_endio() on the bio if it fails to
submit, so cleaning up the bio just leads to a variety of use-after-free
and NULL pointer dereference bugs because we race with the endio
function that is cleaning up the bio.  Instead just return BLK_STS_OK as
the repair function has to continue to process the rest of the pages,
and the endio for the repair bio will do the appropriate cleanup for the
page that it was given.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c