fs/fcb2: fix endless loop in fcb2_getprev if a flash error occurs#2949
fs/fcb2: fix endless loop in fcb2_getprev if a flash error occurs#2949blocksebastian wants to merge 1 commit intoapache:masterfrom
Conversation
| } | ||
| loc->fe_entry_num++; | ||
| } while (1); | ||
| } while (rc == 0); |
There was a problem hiding this comment.
Endless loop was supposed to handle cases where FCB2 had corrupted entries (most likely CRC for broken writes).
I guess then in your case, due to some flash read error, loop would not finish.
FCB2 sector starts with header fcb2_disk_area; data is stored in flash after the header starting from the beginning while entries holding CRC and data position and length are stored starting from the end of the sector.
When read error occurs fe_entry_num should be increased like it is right now but some sanity check should be performed to see if probably entry does not reach to occupied space or header if read error persist.
I guess similar check is done when new data is being written to FCB and there is not space for data+entry.
Proposed solution does not cover case where there are some errors in flash that could be recovered.
| last_valid = loc->fe_entry_num; | ||
| } | ||
| if (rc == FCB2_ERR_NOVAR) { | ||
| else if (rc == FCB2_ERR_NOVAR) { |
There was a problem hiding this comment.
else should be in previous line to keep coding style presistant
fcb2_sector_find_last does not return or break while loop if an error occured during read