Commit c7e9309
block: fix infinite loop in badblocks_clear() and badblocks_check()
An infinite loop can occur in both _badblocks_clear() and _badblocks_check()
when BB_OFFSET() equals the start position, 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 three code paths:
1. _badblocks_clear() at line 1100 (start before all badblocks)
2. _badblocks_clear() at line 1153 (behind overlap check)
3. _badblocks_check() at line 1240 (behind overlap check)
Add checks in all three locations to ensure len is non-zero before
entering the loop.
Signed-off-by: Ramesh Adhikari <[email protected]>1 parent 857ada9 commit c7e9309
1 file changed
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1098 | 1098 | | |
1099 | 1099 | | |
1100 | 1100 | | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
1101 | 1105 | | |
1102 | 1106 | | |
1103 | 1107 | | |
| |||
1151 | 1155 | | |
1152 | 1156 | | |
1153 | 1157 | | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
1154 | 1162 | | |
1155 | 1163 | | |
1156 | 1164 | | |
| |||
1234 | 1242 | | |
1235 | 1243 | | |
1236 | 1244 | | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
1237 | 1249 | | |
1238 | 1250 | | |
1239 | 1251 | | |
| |||
0 commit comments