mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-09-01 06:39:05 +00:00
ubi: block: fix memleak in ubiblock_create()
If idr_alloc() fails, dev->gd will be put after goto out_cleanup_disk in ubiblock_create(), but dev->gd has not been assigned yet at this time, and 'gd' will not be put anymore. Fix it by putting 'gd' directly. Signed-off-by: Li Nan <linan122@huawei.com> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
parent
ac8e9f64f5
commit
adbf4c4954
@ -434,7 +434,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
|
|||||||
list_del(&dev->list);
|
list_del(&dev->list);
|
||||||
idr_remove(&ubiblock_minor_idr, gd->first_minor);
|
idr_remove(&ubiblock_minor_idr, gd->first_minor);
|
||||||
out_cleanup_disk:
|
out_cleanup_disk:
|
||||||
put_disk(dev->gd);
|
put_disk(gd);
|
||||||
out_free_tags:
|
out_free_tags:
|
||||||
blk_mq_free_tag_set(&dev->tag_set);
|
blk_mq_free_tag_set(&dev->tag_set);
|
||||||
out_free_dev:
|
out_free_dev:
|
||||||
|
Loading…
Reference in New Issue
Block a user