Skip to content

Commit adbf4c4

Browse files
Li Nanrichardweinberger
authored andcommitted
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>
1 parent ac8e9f6 commit adbf4c4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/mtd/ubi/block.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
434434
list_del(&dev->list);
435435
idr_remove(&ubiblock_minor_idr, gd->first_minor);
436436
out_cleanup_disk:
437-
put_disk(dev->gd);
437+
put_disk(gd);
438438
out_free_tags:
439439
blk_mq_free_tag_set(&dev->tag_set);
440440
out_free_dev:

0 commit comments

Comments
 (0)