All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: <richard@nod.at>, <daniel@makrotopia.org>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2] ubi: ubi_init: Fix missed ubiblock cleanup in error handling path
Date: Wed, 10 Apr 2024 15:40:33 +0800	[thread overview]
Message-ID: <20240410074033.2523399-3-chengzhihao1@huawei.com> (raw)
In-Reply-To: <20240410074033.2523399-1-chengzhihao1@huawei.com>

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.

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();
 	unregister_mtd_user(&ubi_mtd_notifier);
 out_debugfs:
 	ubi_debugfs_exit();
-- 
2.39.2


WARNING: multiple messages have this Message-ID (diff)
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: <richard@nod.at>, <daniel@makrotopia.org>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2] ubi: ubi_init: Fix missed ubiblock cleanup in error handling path
Date: Wed, 10 Apr 2024 15:40:33 +0800	[thread overview]
Message-ID: <20240410074033.2523399-3-chengzhihao1@huawei.com> (raw)
In-Reply-To: <20240410074033.2523399-1-chengzhihao1@huawei.com>

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.

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();
 	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/

  parent reply	other threads:[~2024-04-10  7:49 UTC|newest]

Thread overview: 14+ 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 ` 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   ` Zhihao Cheng
2024-04-10  7:40 ` Zhihao Cheng [this message]
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 22:41     ` kernel test robot
2024-04-10 23:10   ` Daniel Golle
2024-04-10 23:10     ` Daniel Golle
2024-04-11  2:39     ` Zhihao Cheng
2024-04-11  2:39       ` Zhihao Cheng
2024-04-11 15:40   ` kernel test robot
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=20240410074033.2523399-3-chengzhihao1@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=daniel@makrotopia.org \
    --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 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.