mirror of https://github.com/torvalds/linux.git
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 <dan.carpenter@linaro.org> Signed-off-by: Coly Li <colyli@kernel.org> Reviewed-by: Yu Kuai <yukuai3@huawei.com> Link: https://lore.kernel.org/r/20250309160556.42854-1-colyli@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
fc0e982b8a
commit
7e76336e14
|
|
@ -1242,14 +1242,15 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, sector_t sectors,
|
||||||
len = sectors;
|
len = sectors;
|
||||||
|
|
||||||
update_sectors:
|
update_sectors:
|
||||||
|
/* This situation should never happen */
|
||||||
|
WARN_ON(sectors < len);
|
||||||
|
|
||||||
s += len;
|
s += len;
|
||||||
sectors -= len;
|
sectors -= len;
|
||||||
|
|
||||||
if (sectors > 0)
|
if (sectors > 0)
|
||||||
goto re_check;
|
goto re_check;
|
||||||
|
|
||||||
WARN_ON(sectors < 0);
|
|
||||||
|
|
||||||
if (unacked_badblocks > 0)
|
if (unacked_badblocks > 0)
|
||||||
rv = -1;
|
rv = -1;
|
||||||
else if (acked_badblocks > 0)
|
else if (acked_badblocks > 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue