linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] m68k/amiga: missing platform_device_unregister() on error in amiga_init_devices()
@ 2020-07-28  2:27 Qinglang Miao
  2020-08-26  9:07 ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Qinglang Miao @ 2020-07-28  2:27 UTC (permalink / raw)
  To: Geert Uytterhoeven, Stephen Rothwell, Greg Kroah-Hartman
  Cc: linux-m68k, linux-kernel

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>
---
 arch/m68k/amiga/platform.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/m68k/amiga/platform.c b/arch/m68k/amiga/platform.c
index d34029d7b..afa2782c6 100644
--- 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));
-		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);
 			return error;
+		}
 	}
 
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] m68k/amiga: missing platform_device_unregister() on error in amiga_init_devices()
  2020-07-28  2:27 [PATCH -next] m68k/amiga: missing platform_device_unregister() on error in amiga_init_devices() Qinglang Miao
@ 2020-08-26  9:07 ` Geert Uytterhoeven
  2020-09-19  1:30   ` miaoqinglang
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2020-08-26  9:07 UTC (permalink / raw)
  To: Qinglang Miao
  Cc: Stephen Rothwell, Greg Kroah-Hartman, linux-m68k,
	Linux Kernel Mailing List

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.

> -               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

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] m68k/amiga: missing platform_device_unregister() on error in amiga_init_devices()
  2020-08-26  9:07 ` Geert Uytterhoeven
@ 2020-09-19  1:30   ` miaoqinglang
  0 siblings, 0 replies; 3+ messages in thread
From: miaoqinglang @ 2020-09-19  1:30 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Stephen Rothwell, Greg Kroah-Hartman, linux-m68k,
	Linux Kernel Mailing List



在 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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-19  1:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28  2:27 [PATCH -next] m68k/amiga: missing platform_device_unregister() on error in amiga_init_devices() Qinglang Miao
2020-08-26  9:07 ` Geert Uytterhoeven
2020-09-19  1:30   ` miaoqinglang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).