linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Qinglang Miao <miaoqinglang@huawei.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-m68k <linux-m68k@lists.linux-m68k.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next] m68k/amiga: missing platform_device_unregister() on error in amiga_init_devices()
Date: Wed, 26 Aug 2020 11:07:15 +0200	[thread overview]
Message-ID: <CAMuHMdWfqh_AKyE+od_0yVPP6Lkv8LUAR1dWf8Df94W7b4qxLA@mail.gmail.com> (raw)
In-Reply-To: <20200728022746.87612-1-miaoqinglang@huawei.com>

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

  reply	other threads:[~2020-08-26  9:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-09-19  1:30   ` miaoqinglang

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=CAMuHMdWfqh_AKyE+od_0yVPP6Lkv8LUAR1dWf8Df94W7b4qxLA@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=miaoqinglang@huawei.com \
    --cc=sfr@canb.auug.org.au \
    /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 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).