From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Yuho Choi <dbgh9129@gmail.com>,
Richard Weinberger <richard@nod.at>,
Miquel Raynal <miquel.raynal@bootlin.com>
Cc: <linux-mtd@lists.infradead.org>,
Vignesh Raghavendra <vigneshr@ti.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] mtd: ubi: Fix rollback for explicit UBI device numbers
Date: Mon, 8 Jun 2026 12:45:03 +0800 [thread overview]
Message-ID: <52a0fcca-57ab-12b4-63d1-cdd648bf8254@huawei.com> (raw)
In-Reply-To: <20260608040639.2616638-1-dbgh9129@gmail.com>
在 2026/6/8 12:06, Yuho Choi 写道:
> ubi_init_attach() rolls back module initialization failures by scanning
> ubi_devices[0..i-1], where i is the mtd= parameter index. That assumes
> the parameter index matches the UBI device number.
>
> That assumption is not true when mtd= specifies an explicit ubi_num. A
> successfully attached device can be stored at a higher ubi_devices[]
> slot, and a later failure can miss it during rollback.
>
> Scan the full ubi_devices[] array and detach by the actual array index,
> matching the way UBI devices are stored.
>
> Fixes: 83ff59a06663 ("UBI: support ubi_num on mtd.ubi command line")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---
> drivers/mtd/ubi/build.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index 674ad87809df..90c5c83d90e3 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -1317,10 +1317,10 @@ static int __init ubi_init_attach(void)
> return 0;
>
> out_detach:
> - for (k = 0; k < i; k++)
> + for (k = 0; k < UBI_MAX_DEVICES; k++)
> if (ubi_devices[k]) {
> mutex_lock(&ubi_devices_mutex);
> - ubi_detach_mtd_dev(ubi_devices[k]->ubi_num, 1);
> + ubi_detach_mtd_dev(k, 1);
> mutex_unlock(&ubi_devices_mutex);
> }
> return err;
>
prev parent reply other threads:[~2026-06-08 4:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 4:06 Yuho Choi
2026-06-08 4:45 ` 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=52a0fcca-57ab-12b4-63d1-cdd648bf8254@huawei.com \
--to=chengzhihao1@huawei.com \
--cc=dbgh9129@gmail.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 \
/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®