lkml.org 
[lkml]   [2024]   [Apr]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] ubi: ubi_init: Fix missed ubiblock cleanup in error handling path
Date
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

\
 
 \ /
  Last update: 2024-05-27 16:32    [W:0.103 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site