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 <vkarunam@codeaurora.org>
Change-Id: I5a875ec82266db6b09045602b5d1b3fe47d4bd58
This commit is contained in:
Vandhiadevan Karunamoorthy 2021-08-12 14:06:27 +05:30
parent 081123e558
commit 89f08320cb

View file

@ -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;
}
/*