Commit 8b1b5ba4 authored by Li Nan's avatar Li Nan
Browse files

ubi: block: fix memleak in ubiblock_create()

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8P68G



-------------------------------

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: default avatarLi Nan <linan122@huawei.com>
parent ffaa81fb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -434,7 +434,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
	list_del(&dev->list);
	idr_remove(&ubiblock_minor_idr, gd->first_minor);
out_cleanup_disk:
	put_disk(dev->gd);
	put_disk(gd);
out_free_tags:
	blk_mq_free_tag_set(&dev->tag_set);
out_free_dev: