• Hou Tao's avatar
    ubi: Free the normal volumes in error paths of ubi_attach_mtd_dev() · fc55dacf
    Hou Tao authored
    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: default avatarHou Tao <houtao1@huawei.com>
    Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
    fc55dacf
ubi.h 41.1 KB