ipq806x: Detach ubi on ubi volume read error.

Detach the ubi and the associated mtd device on error conditions.

Change-Id: I7b1fc798b5e03e4b2a39370697a4615139273c15
Signed-off-by: Aditya Kumar Patra S <apatr@codeaurora.org>
This commit is contained in:
Aditya Kumar Patra S 2017-02-06 18:37:47 +05:30 committed by Gerrit - the friendly Code Review server
parent 9349111a4c
commit b55f8a1e4c

View file

@ -524,6 +524,7 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
int64_t size = 0;
ulong addr = 0;
int err = 0;
if (argc < 2)
return CMD_RET_USAGE;
@ -661,7 +662,12 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
printf("Read %lld bytes from volume %s to %lx\n", size,
argv[3], addr);
return ubi_volume_read(argv[3], (char *)addr, size);
err = ubi_volume_read(argv[3], (char *)addr, size);
if (err != 0) {
ubi_detach_mtd_dev(ubi_dev.nr, 1);
put_mtd_device(ubi_dev.mtd_info);
}
return err;
}
}