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, 28 Feb 2022 15:20:04 +0000 (16:20 +0100)
commit9d33f4515a0532ded381064ea1d74ad51530c088
tree8b1ad418de19b4c5e0102e2857c2a4bc06055a8f
parent55d05ca24020ff46c88733e51f999bf5add266e2
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