]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: raid56: avoid double freeing for rbio if full_stripe_write() failed
authorQu Wenruo <wqu@suse.com>
Mon, 10 Oct 2022 10:36:07 +0000 (18:36 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Oct 2022 13:26:56 +0000 (15:26 +0200)
commit65296633be02cfd903c0944e12ab7875fb9a887b
tree4e7fc7142755fe3d85f795974a29e47ffb2acae7
parent1b13b8d70204722488301e2fb2451458e579518a
btrfs: raid56: avoid double freeing for rbio if full_stripe_write() failed

Currently if full_stripe_write() failed to allocate the pages for
parity, it will call __free_raid_bio() first, then return -ENOMEM.

But some caller of full_stripe_write() will also call __free_raid_bio()
again, this would cause double freeing.

And it's not a logically sound either, normally we should either free
the memory at the same level where we allocated it, or let endio to
handle everything.

So this patch will solve the double freeing by make
raid56_parity_write() to handle the error and free the rbio.

Just like what we do in raid56_parity_recover().

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/raid56.c