diff options
author | Li Nan <linan122@huawei.com> | 2023-12-08 15:46:29 +0800 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2024-01-06 23:52:51 +0100 |
commit | adbf4c4954e33e623897058a617c583d65a177f6 (patch) | |
tree | 93cb40f4ea85601e4b8246bd19f7d51b20f5c13e /drivers/mtd | |
parent | ac8e9f64f51b6e61e7181a44525e1d4cd1cb338a (diff) |
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>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/block.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index 309a42aeaa4c..654bd7372cd8 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -434,7 +434,7 @@ out_remove_minor: 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: |