mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
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:aa511ff821("badblocks: switch to the improved badblock handling code") Fixes:c3c6a86e9e("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>
This commit is contained in:
@@ -700,7 +700,7 @@ static bool can_front_overwrite(struct badblocks *bb, int prev,
|
||||
*extra = 2;
|
||||
}
|
||||
|
||||
if ((bb->count + (*extra)) >= MAX_BADBLOCKS)
|
||||
if ((bb->count + (*extra)) > MAX_BADBLOCKS)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -1135,7 +1135,7 @@ re_clear:
|
||||
if ((BB_OFFSET(p[prev]) < bad.start) &&
|
||||
(BB_END(p[prev]) > (bad.start + bad.len))) {
|
||||
/* Splitting */
|
||||
if ((bb->count + 1) < MAX_BADBLOCKS) {
|
||||
if ((bb->count + 1) <= MAX_BADBLOCKS) {
|
||||
len = front_splitting_clear(bb, prev, &bad);
|
||||
bb->count += 1;
|
||||
cleared++;
|
||||
|
||||
Reference in New Issue
Block a user