mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 11:31:31 +00:00
badblocks: avoid checking invalid range in badblocks_check()
If prev_badblocks() returns '-1', it means no valid badblocks record
before the checking range. It doesn't make sense to check whether
the input checking range is overlapped with the non-existed invalid
front range.
This patch checkes whether 'prev >= 0' is true before calling
overlap_front(), to void such invalid operations.
Fixes: 3ea3354cb9
("badblocks: improve badblocks_check() for multiple ranges handling")
Reported-and-tested-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
Link: https://lore.kernel.org/nvdimm/3035e75a-9be0-4bc3-8d4a-6e52c207f277@leemhuis.info/
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Geliang Tang <geliang.tang@suse.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: NeilBrown <neilb@suse.de>
Cc: Vishal L Verma <vishal.l.verma@intel.com>
Cc: Xiao Ni <xni@redhat.com>
Link: https://lore.kernel.org/r/20231224002820.20234-1-colyli@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
13d822bf1c
commit
146e843f6b
@ -1312,12 +1312,14 @@ re_check:
|
|||||||
prev = prev_badblocks(bb, &bad, hint);
|
prev = prev_badblocks(bb, &bad, hint);
|
||||||
|
|
||||||
/* start after all badblocks */
|
/* start after all badblocks */
|
||||||
if ((prev + 1) >= bb->count && !overlap_front(bb, prev, &bad)) {
|
if ((prev >= 0) &&
|
||||||
|
((prev + 1) >= bb->count) && !overlap_front(bb, prev, &bad)) {
|
||||||
len = sectors;
|
len = sectors;
|
||||||
goto update_sectors;
|
goto update_sectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overlap_front(bb, prev, &bad)) {
|
/* Overlapped with front badblocks record */
|
||||||
|
if ((prev >= 0) && overlap_front(bb, prev, &bad)) {
|
||||||
if (BB_ACK(p[prev]))
|
if (BB_ACK(p[prev]))
|
||||||
acked_badblocks++;
|
acked_badblocks++;
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user