Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

badblocks: fix the using of MAX_BADBLOCKS

The number of badblocks cannot exceed MAX_BADBLOCKS, but it should be
allowed to equal MAX_BADBLOCKS.

Fixes: aa511ff8218b ("badblocks: switch to the improved badblock handling code")
Fixes: c3c6a86e9efc ("badblocks: add helper routines for badblock ranges handling")
Signed-off-by: Li Nan <linan122@huawei.com>
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Acked-by: Coly Li <colyli@kernel.org>
Link: https://lore.kernel.org/r/20250227075507.151331-7-zhengqixing@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Li Nan and committed by
Jens Axboe
37446680 7f500f0a

+2 -2
+2 -2
block/badblocks.c
··· 700 700 *extra = 2; 701 701 } 702 702 703 - if ((bb->count + (*extra)) >= MAX_BADBLOCKS) 703 + if ((bb->count + (*extra)) > MAX_BADBLOCKS) 704 704 return false; 705 705 706 706 return true; ··· 1135 1135 if ((BB_OFFSET(p[prev]) < bad.start) && 1136 1136 (BB_END(p[prev]) > (bad.start + bad.len))) { 1137 1137 /* Splitting */ 1138 - if ((bb->count + 1) < MAX_BADBLOCKS) { 1138 + if ((bb->count + 1) <= MAX_BADBLOCKS) { 1139 1139 len = front_splitting_clear(bb, prev, &bad); 1140 1140 bb->count += 1; 1141 1141 cleared++;