Message ID | 20231223063728.3229446-4-linan666@huaweicloud.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | badblocks: bugfix and cleanup of _badblocks_check() | expand |
diff --git a/block/badblocks.c b/block/badblocks.c index 054d05b93641..71a3e43351da 100644 --- a/block/badblocks.c +++ b/block/badblocks.c @@ -1316,7 +1316,7 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, int sectors, goto out; } - if (overlap_front(bb, prev, &bad)) { + if (prev >= 0 && overlap_front(bb, prev, &bad)) { if (set == 0) { *first_bad = BB_OFFSET(p[prev]); *bad_sectors = BB_LEN(p[prev]);