@@ -1296,6 +1296,11 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, int sectors,
retry:
seq = read_seqbegin(&bb->lock);
+ if (badblocks_empty(bb)) {
+ len = sectors;
+ goto out;
+ }
+
p = bb->page;
acked_badblocks = 0;
@@ -1303,17 +1308,12 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, int sectors,
bad.start = s;
bad.len = sectors;
- if (badblocks_empty(bb)) {
- len = sectors;
- goto update_sectors;
- }
-
prev = prev_badblocks(bb, &bad, hint);
/* start after all badblocks */
if ((prev + 1) >= bb->count && !overlap_front(bb, prev, &bad)) {
len = sectors;
- goto update_sectors;
+ goto out;
}
if (overlap_front(bb, prev, &bad)) {
@@ -1339,7 +1339,7 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, int sectors,
}
/* Not front overlap, but behind overlap */
- if ((prev + 1) < bb->count && overlap_behind(bb, &bad, prev + 1)) {
+ if (overlap_behind(bb, &bad, prev + 1)) {
len = BB_OFFSET(p[prev + 1]) - bad.start;
hint = prev + 1;
goto update_sectors;