[PATCH] mtd: core: only increment ecc_stats.badblocks on confirmed good->bad transition

Miquel Raynal miquel.raynal at bootlin.com
Tue Sep 2 02:20:02 PDT 2025


Hello,

>> Said otherwise, the { while () badblocks++ } block shall remain outside
>> of the if (_block_isbad) condition and remain untouched. Just bail out
>> early if you are sure this is not needed.
>> 
>
> I’ll send a V2 shortly that:
>
> - Checks old state when _block_isbad exists and bails out early if already bad
> - Otherwise calls ->_block_markbad() and increments the counter on success, with
>   the increment left outside of the conditional as you suggested

LGTM.

Thanks,
Miquèl



More information about the linux-mtd mailing list