From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: <daniel@makrotopia.org>, <linux-kernel@vger.kernel.org>,
<linux-mtd@lists.infradead.org>, <miquel.raynal@bootlin.com>,
<richard@nod.at>, <vigneshr@ti.com>, <stable@vger.kernel.org>
Subject: Re: [PATCH] mtd: ubi: Fix UBI device reference leak in ubi_detach_mtd_dev()
Date: Thu, 17 Sep 2026 19:20:35 +0800 [thread overview]
Message-ID: <103ef14f-85e7-8f4d-4ba4-eab5e36ddfe2@huawei.com> (raw)
In-Reply-To: <20260917103102.2147038-1-vulab@iscas.ac.cn>
在 2026/9/17 18:31, Wentao Liang 写道:
> ubi_detach_mtd_dev() takes a reference on the UBI device with
> ubi_get_device() and drops the matching kobject reference only after
> the shutdown notification has been sent. When the device is still in
> use and a forced detach was not requested, the function returns -EBUSY
> before that put_device(), so the reference taken by ubi_get_device() is
> never released and the device is never freed.
>
> Drop the reference on the busy path as well.
>
> Fixes: 7e84c961b2eb ("mtd: ubi: introduce pre-removal notification for UBI volumes")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/mtd/ubi/build.c | 1 +
> 1 file changed, 1 insertion(+)
Hi, Wentao, it has been fixed by [1].
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/mtd/ubi/build.c?id=31dd710cd84d5dd63c49f640d3a9f36c9699ca95
>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index 674ad87809df..d81f5e0395ac 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -1106,6 +1106,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
> if (ubi->ref_count) {
> if (!anyway) {
> spin_unlock(&ubi_devices_lock);
> + put_device(&ubi->dev);
> return -EBUSY;
> }
> /* This may only happen if there is a bug */
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
prev parent reply other threads:[~2026-09-17 11:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 10:31 [PATCH] mtd: ubi: Fix UBI device reference leak in ubi_detach_mtd_dev() Wentao Liang
2026-09-17 10:40 ` sashiko-bot
2026-09-17 11:20 ` Zhihao Cheng [this message]
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=103ef14f-85e7-8f4d-4ba4-eab5e36ddfe2@huawei.com \
--to=chengzhihao1@huawei.com \
--cc=daniel@makrotopia.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=stable@vger.kernel.org \
--cc=vigneshr@ti.com \
--cc=vulab@iscas.ac.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.