diff options
author | Hou Tao <houtao1@huawei.com> | 2019-11-30 10:48:25 +0100 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2020-01-16 23:35:59 +0100 |
commit | fc55dacf7fea793e70c9c75a1acff47a4fb02017 (patch) | |
tree | 322ea53989f168fdce2826455193d77364dadf43 /drivers/mtd/ubi/attach.c | |
parent | ubi: Check the presence of volume before call ubi_fastmap_destroy_checkmap() (diff) | |
download | linux-fc55dacf7fea793e70c9c75a1acff47a4fb02017.tar.xz linux-fc55dacf7fea793e70c9c75a1acff47a4fb02017.zip |
ubi: Free the normal volumes in error paths of ubi_attach_mtd_dev()
The allocated normal volumes saved in ubi->volumes are not freed
in the error paths in ubi_attach_mtd_dev() and its callees (e.g.
ubi_attach() and ubi_read_volume_table()).
These normal volumes should be freed through kill_volumes() and
vol_release(), but ubi_attach_mtd_dev() may fail before
calling uif_init(), and there will be memory leaks.
So adding a new helper ubi_free_all_volumes() to free the normal
and the internal volumes. And in order to prevent double-free
of volume, reset ubi->volumes[i] to NULL after freeing.
Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'drivers/mtd/ubi/attach.c')
-rw-r--r-- | drivers/mtd/ubi/attach.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c index 10b2459f8951..ea7440ac913b 100644 --- a/drivers/mtd/ubi/attach.c +++ b/drivers/mtd/ubi/attach.c @@ -1640,7 +1640,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan) out_wl: ubi_wl_close(ubi); out_vtbl: - ubi_free_internal_volumes(ubi); + ubi_free_all_volumes(ubi); vfree(ubi->vtbl); out_ai: destroy_ai(ai); |