mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: <linan666@huaweicloud.com>, <richard@nod.at>,
	<miquel.raynal@bootlin.com>, <vigneshr@ti.com>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	<linan122@huawei.com>, <yukuai3@huawei.com>,
	<yi.zhang@huawei.com>, <houtao1@huawei.com>,
	<yangerkun@huawei.com>
Subject: Re: [PATCH] ubi: block: fix null-pointer-dereference in ubiblock_create()
Date: Fri, 8 Dec 2023 15:29:35 +0800	[thread overview]
Message-ID: <a1e3aa71-d89e-0579-b55f-125c17b45f29@huawei.com> (raw)
In-Reply-To: <20231208071317.1268465-1-linan666@huaweicloud.com>

在 2023/12/8 15:13, linan666@huaweicloud.com 写道:
> From: Li Nan <linan122@huawei.com>
>
> 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
> accessing it will trigger a null-pointer-dereference issue. Fix it by put
> gd directly.
Function 'put_disk()' checks disk whether is NULL, so I think it's a 
'memleak' problem, not a null-ptr-deref problem.
>
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
>   drivers/mtd/ubi/block.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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 @@ 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);

For memleak solution:

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>

>   out_free_tags:
>   	blk_mq_free_tag_set(&dev->tag_set);
>   out_free_dev:



  reply	other threads:[~2023-12-08  7:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08  7:13 linan666
2023-12-08  7:29 ` Zhihao Cheng [this message]
2023-12-08  7:40   ` Li Nan
2024-04-28  7:19 linan666
2024-04-28  7:51 ` Zhihao Cheng
2024-05-06 13:35   ` Li Nan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a1e3aa71-d89e-0579-b55f-125c17b45f29@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=houtao1@huawei.com \
    --cc=linan122@huawei.com \
    --cc=linan666@huaweicloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®