Re: btrfs: scrub: fix memory leak in scrub_raid56_parity_stripe()

From: Qu Wenruo

Date: Thu Nov 06 2025 - 02:02:20 EST




在 2025/11/6 17:25, Markus Elfring 写道:

Add the missing bio_put() calls to properly drop the bio reference
in those error cases.

How do you think about to use additional labels?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.18-rc4#n526

I believe the current hot fix is fine.


Would you like to care a bit more for avoidance of duplicate source code
(also according to better exception handling)?

That is handled in this patch, a dedicated cleanup/refactor:

https://lore.kernel.org/linux-btrfs/2d2cfb7729a65d88ea8b9d6408611d0cc76e1ab7.1762398098.git.wqu@xxxxxxxx/T/#u

To be honest, doing that extra tag inside the original scrub_raid56_parity_stripe() is not that helpful, that function is doing a lot of different works, and @bio is only allocated for the last two stages (using cached stripes and to wait for the scrub of parity stripe).

Doing a dedicated tag for less than half of the code is not going to improve readability.

It's better to extract the unrelated behavior into a dedicated helper so that it's way straight forward.

Thanks,
Qu


Regards,
Markus