aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/fastmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/fastmap.c')
-rw-r--r--drivers/mtd/ubi/fastmap.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 2cf2506b8f44..762e25c6a2d2 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -1385,7 +1385,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)
1385 1385
1386 ret = -ENOSPC; 1386 ret = -ENOSPC;
1387 goto err; 1387 goto err;
1388 } else if (!tmp_e && old_fm) { 1388 } else if (!tmp_e && old_fm && old_fm->e[i]) {
1389 ret = erase_block(ubi, old_fm->e[i]->pnum); 1389 ret = erase_block(ubi, old_fm->e[i]->pnum);
1390 if (ret < 0) { 1390 if (ret < 0) {
1391 int j; 1391 int j;
@@ -1401,12 +1401,20 @@ int ubi_update_fastmap(struct ubi_device *ubi)
1401 } else { 1401 } else {
1402 new_fm->e[i] = tmp_e; 1402 new_fm->e[i] = tmp_e;
1403 1403
1404 if (old_fm) 1404 if (old_fm && old_fm->e[i])
1405 ubi_wl_put_fm_peb(ubi, old_fm->e[i], i, 1405 ubi_wl_put_fm_peb(ubi, old_fm->e[i], i,
1406 old_fm->to_be_tortured[i]); 1406 old_fm->to_be_tortured[i]);
1407 } 1407 }
1408 } 1408 }
1409 1409
1410 /* Old fastmap is larger than the new one */
1411 if (old_fm && new_fm->used_blocks < old_fm->used_blocks) {
1412 for (i = new_fm->used_blocks; i < old_fm->used_blocks; i++) {
1413 ubi_wl_put_fm_peb(ubi, old_fm->e[i], i,
1414 old_fm->to_be_tortured[i]);
1415 }
1416 }
1417
1410 spin_lock(&ubi->wl_lock); 1418 spin_lock(&ubi->wl_lock);
1411 tmp_e = ubi_wl_get_fm_peb(ubi, 1); 1419 tmp_e = ubi_wl_get_fm_peb(ubi, 1);
1412 spin_unlock(&ubi->wl_lock); 1420 spin_unlock(&ubi->wl_lock);