Skip to content

Commit 81a526c

Browse files
committed
WearLevel: fail-safe if erasing block fails
1 parent fad694b commit 81a526c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

util/wear_level.hh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ public:
6464
if (cell_ >= Storage::NumCells) {
6565
if (erased_once)
6666
return false;
67-
if (!storage.erase())
67+
if (!storage.erase()) {
68+
cell_ = 0;
6869
return false;
70+
}
6971
cell_ = 0;
7072
erased_once = true;
7173
}

0 commit comments

Comments
 (0)