[PATCH 1/2] ubi: check the presence of volume before call ubi_fastmap_destroy_checkmap()

Hou Tao houtao1 at huawei.com
Sat Nov 30 01:48:00 PST 2019


Else there may be oops when fastmap is enabled and init_volumes() fails.

Signed-off-by: Hou Tao <houtao1 at huawei.com>
---
 drivers/mtd/ubi/vtbl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 53d8ab54e181..8a2a0f091598 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -852,6 +852,8 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
 out_free:
 	vfree(ubi->vtbl);
 	for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) {
+		if (!ubi->volumes[i])
+			continue;
 		ubi_fastmap_destroy_checkmap(ubi->volumes[i]);
 		kfree(ubi->volumes[i]);
 		ubi->volumes[i] = NULL;
-- 
2.22.0




More information about the linux-mtd mailing list