lkml.org 
[lkml]   [2024]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/2] ubi: ubi_init: Fix missed ubiblock cleanup in error handling path
From
Date
在 2024/4/11 7:10, Daniel Golle 写道:
> 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).
>

My mistake, I always forget to check make W=1, I will send a new version
to combine Ben's modifications. Thanks to point that.
>
>> unregister_mtd_user(&ubi_mtd_notifier);
>> out_debugfs:
>> ubi_debugfs_exit();
>> --
>> 2.39.2
>>
> .
>


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