Skip to content

Commit 7e76336

Browse files
Coly Liaxboe
authored andcommitted
badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0
In _badblocks_check(), there are lines of code like this, 1246 sectors -= len; [snipped] 1251 WARN_ON(sectors < 0); The WARN_ON() at line 1257 doesn't make sense because sectors is unsigned long long type and never to be <0. Fix it by checking directly checking whether sectors is less than len. Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Coly Li <[email protected]> Reviewed-by: Yu Kuai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent fc0e982 commit 7e76336

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

block/badblocks.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,14 +1242,15 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, sector_t sectors,
12421242
len = sectors;
12431243

12441244
update_sectors:
1245+
/* This situation should never happen */
1246+
WARN_ON(sectors < len);
1247+
12451248
s += len;
12461249
sectors -= len;
12471250

12481251
if (sectors > 0)
12491252
goto re_check;
12501253

1251-
WARN_ON(sectors < 0);
1252-
12531254
if (unacked_badblocks > 0)
12541255
rv = -1;
12551256
else if (acked_badblocks > 0)

0 commit comments

Comments
 (0)