From 89f08320cb2d940a7d28b76815711d13c3abda79 Mon Sep 17 00:00:00 2001 From: Vandhiadevan Karunamoorthy Date: Thu, 12 Aug 2021 14:06:27 +0530 Subject: [PATCH] common: ubi: fix ubi_initialized flag handling This patch clears the ubi_initialized flag after doing ubi_exit since there can be chance to ubi_int failure, but still ubi_initialized flag will be set. This will result in doing ubi_exit again and uboot crash. This patch also doing put_mtd_device after deleting mtd partition to make the ref count to zero. Signed-off-by: Vandhiadevan Karunamoorthy Change-Id: I5a875ec82266db6b09045602b5d1b3fe47d4bd58 --- common/cmd_ubi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index 394a169a4a..e00dd66d55 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -486,6 +486,8 @@ int ubi_part(char *part_name, const char *vid_header_offset) if (ubi_initialized) { ubi_exit(); del_mtd_partitions(ubi_dev.mtd_info); + put_mtd_device(ubi_dev.mtd_info); + ubi_initialized = 0; } /*