ubi: block: fix memleak in ubiblock_create()
authorLi Nan <linan122@huawei.com>
Fri, 8 Dec 2023 07:46:29 +0000 (15:46 +0800)
committerRichard Weinberger <richard@nod.at>
Sat, 6 Jan 2024 22:52:51 +0000 (23:52 +0100)
commitadbf4c4954e33e623897058a617c583d65a177f6
tree93cb40f4ea85601e4b8246bd19f7d51b20f5c13e
parentac8e9f64f51b6e61e7181a44525e1d4cd1cb338a
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>
drivers/mtd/ubi/block.c