Commit b27d89c
block: fix infinite loop in badblocks_clear()
An infinite loop can occur in _badblocks_clear() when BB_OFFSET(p[prev + 1])
equals bad.start, resulting in len = 0. This causes the update_sectors loop
to spin forever without making progress:
s += 0; // no advancement
sectors -= 0; // stays positive
goto re_clear; // infinite loop
The bug exists in two code paths:
1. _badblocks_clear() at line 1153 (behind overlap check)
2. _badblocks_check() at line 1240 (behind overlap check)
Add checks in both functions to ensure len is non-zero before entering
the loop.
Signed-off-by: Ramesh Adhikari <[email protected]>1 parent 857ada9 commit b27d89c
1 file changed
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1151 | 1151 | | |
1152 | 1152 | | |
1153 | 1153 | | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
1154 | 1158 | | |
1155 | 1159 | | |
1156 | 1160 | | |
| |||
1234 | 1238 | | |
1235 | 1239 | | |
1236 | 1240 | | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
1237 | 1245 | | |
1238 | 1246 | | |
1239 | 1247 | | |
| |||
0 commit comments