Skip to content

Commit 3744668

Browse files
Li Nanaxboe
authored andcommitted
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: aa511ff ("badblocks: switch to the improved badblock handling code") Fixes: c3c6a86 ("badblocks: add helper routines for badblock ranges handling") Signed-off-by: Li Nan <[email protected]> Reviewed-by: Zhu Yanjun <[email protected]> Reviewed-by: Yu Kuai <[email protected]> Acked-by: Coly Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 7f500f0 commit 3744668

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

block/badblocks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ static bool can_front_overwrite(struct badblocks *bb, int prev,
700700
*extra = 2;
701701
}
702702

703-
if ((bb->count + (*extra)) >= MAX_BADBLOCKS)
703+
if ((bb->count + (*extra)) > MAX_BADBLOCKS)
704704
return false;
705705

706706
return true;
@@ -1135,7 +1135,7 @@ static int _badblocks_clear(struct badblocks *bb, sector_t s, int sectors)
11351135
if ((BB_OFFSET(p[prev]) < bad.start) &&
11361136
(BB_END(p[prev]) > (bad.start + bad.len))) {
11371137
/* Splitting */
1138-
if ((bb->count + 1) < MAX_BADBLOCKS) {
1138+
if ((bb->count + 1) <= MAX_BADBLOCKS) {
11391139
len = front_splitting_clear(bb, prev, &bad);
11401140
bb->count += 1;
11411141
cleared++;

0 commit comments

Comments
 (0)