lkml.org 
[lkml]   [2020]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH -next] m68k/amiga: missing platform_device_unregister() on error in amiga_init_devices()
From
Date


在 2020/8/26 17:07, Geert Uytterhoeven 写道:
> Hi Qinglang,
>
> On Tue, Jul 28, 2020 at 4:24 AM Qinglang Miao <miaoqinglang@huawei.com> wrote:
>> Add the missing platform_device_unregister() before return
>> from amiga_init_devices() in the error handling case.
>>
>> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
>
> Thanks for your patch!
>
>> --- a/arch/m68k/amiga/platform.c
>> +++ b/arch/m68k/amiga/platform.c
>> @@ -188,8 +188,10 @@ static int __init amiga_init_devices(void)
>> return PTR_ERR(pdev);
>> error = platform_device_add_data(pdev, &a1200_ide_pdata,
>> sizeof(a1200_ide_pdata));
>
> The only reason why platform_device_add_data() can fail is because the
> system ran out of memory. If that's the case this early, the whole
> system will fail to work anyway, and it doesn't matter that the IDE
> driver will crash later due to missing platform data.
>
> So I don't think it helps to increase kernel size by adding more error
> handling.
>
Hi Geert,

Glad to know your opnions, it sounds resonable to me.

Thanks.

>> - if (error)
>> + if (error) {
>> + platform_device_unregister(pdev);
>> return error;
>> + }
>> }
>>
>> if (AMIGAHW_PRESENT(A4000_IDE)) {
>> @@ -199,8 +201,10 @@ static int __init amiga_init_devices(void)
>> return PTR_ERR(pdev);
>> error = platform_device_add_data(pdev, &a4000_ide_pdata,
>> sizeof(a4000_ide_pdata));
>> - if (error)
>> + if (error) {
>> + platform_device_unregister(pdev);
>
> Likewise.
>
>> return error;
>> + }
>
> Gr{oetje,eeting}s,
>
> Geert
>

\
 
 \ /
  Last update: 2020-09-19 03:31    [W:0.045 / U:25.828 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site