From: Daniel Golle <daniel@makrotopia.org>
To: Zhihao Cheng <chengzhihao1@huawei.com>
Cc: richard@nod.at, linux-mtd@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] ubi: ubi_init: Fix missed ubiblock cleanup in error handling path
Date: Thu, 11 Apr 2024 00:10:55 +0100 [thread overview]
Message-ID: <Zhccfw4HbC_MKj65@makrotopia.org> (raw)
In-Reply-To: <20240410074033.2523399-3-chengzhihao1@huawei.com>
Hi!
On Wed, Apr 10, 2024 at 03:40:33PM +0800, Zhihao Cheng wrote:
> The ubiblock_init called by ubi_init will register device number, but
> device number is not released in error handling path of ubi_init when
> ubi is loaded by inserting module (eg. attaching failure), which leads
> to subsequent ubi_init calls failed by running out of device number
> (dmesg shows that "__register_blkdev: failed to get major for ubiblock").
> Fix it by invoking ubiblock_exit() in corresponding error handling path.
Thank you for taking care of this issue.
See my comment inline below:
>
> Fixes: 927c145208b0 ("mtd: ubi: attach from device tree")
> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
> ---
> drivers/mtd/ubi/build.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index 7f95fd7968a8..354517194099 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -1380,12 +1380,13 @@ static int __init ubi_init(void)
> if (ubi_is_module()) {
> err = ubi_init_attach();
> if (err)
> - goto out_mtd_notifier;
> + goto out_block_exit;
> }
>
> return 0;
>
> -out_mtd_notifier:
> +out_block_exit:
> + ubiblock_exit();
I believe that this call is the reason for the section mismatch we
are seeing on Intel's kernel test builds:
https://lore.kernel.org/oe-kbuild-all/202404110656.wLLc5mHR-lkp@intel.com/
Also note that Ben Hutchings has supplied a more complete and imho
better solution for this problem, which yet still suffers from the
same problem (calling __exit function from __init function which
results in section mismatch).
> unregister_mtd_user(&ubi_mtd_notifier);
> out_debugfs:
> ubi_debugfs_exit();
> --
> 2.39.2
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2024-04-10 23:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-10 7:40 [PATCH 0/2] ubi: Fix resource leaking in error handling path of ubi_init Zhihao Cheng
2024-04-10 7:40 ` [PATCH 1/2] ubi: ubi_init: Fix missed debugfs cleanup in error handling path Zhihao Cheng
2024-04-10 7:40 ` [PATCH 2/2] ubi: ubi_init: Fix missed ubiblock " Zhihao Cheng
2024-04-10 22:41 ` kernel test robot
2024-04-10 23:10 ` Daniel Golle [this message]
2024-04-11 2:39 ` Zhihao Cheng
2024-04-11 15:40 ` kernel test robot
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=Zhccfw4HbC_MKj65@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=chengzhihao1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
/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