mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
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]>
This commit is contained in:
+3
-2
@@ -1242,14 +1242,15 @@ re_check:
|
||||
len = sectors;
|
||||
|
||||
update_sectors:
|
||||
/* This situation should never happen */
|
||||
WARN_ON(sectors < len);
|
||||
|
||||
s += len;
|
||||
sectors -= len;
|
||||
|
||||
if (sectors > 0)
|
||||
goto re_check;
|
||||
|
||||
WARN_ON(sectors < 0);
|
||||
|
||||
if (unacked_badblocks > 0)
|
||||
rv = -1;
|
||||
else if (acked_badblocks > 0)
|
||||
|
||||
Reference in New Issue
Block a user