All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Jackie Liu <liu.yun@linux.dev>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
	"moderated list:ARM/SAMSUNG EXYNOS ARM ARCHITECTURES" 
	<linux-samsung-soc@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Jackie Liu <liuyun01@kylinos.cn>
Subject: Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
Date: Tue, 26 Oct 2021 17:10:39 +0200	[thread overview]
Message-ID: <CAK8P3a2AxmdhGKhGxfQetfzE0nKaaTRBmX=0OEPoaxkkZwABNg@mail.gmail.com> (raw)
In-Reply-To: <20210901123557.1043953-1-liu.yun@linux.dev>

On Wed, Sep 1, 2021 at 2:35 PM Jackie Liu <liu.yun@linux.dev> wrote:

> +               /* For platform based machines, neither ERR nor NULL can happen here.
> +                * The s3c24xx_handle_irq() will be set as IRQ handler iff this succeeds:
> +                *
> +                *    s3c_intc[0] = s3c24xx_init_intc()
> +                *
> +                * If this fails, the next calls to s3c24xx_init_intc() won't be executed.
> +                *
> +                * For DT machine, s3c_init_intc_of() could set the IRQ handler without
> +                * setting s3c_intc[0] only if it was called with num_ctrl=0. There is no
> +                * such code path, so again the s3c_intc[0] will have a valid pointer if
> +                * set_handle_irq() is called.
> +                *
> +                * Therefore in s3c24xx_handle_irq(), the s3c_intc[0] is always something.
> +                */
> +               if (s3c24xx_handle_intc(s3c_intc[0], regs, 0))
> +                       continue;
>
> -               if (s3c_intc[2])
> +               if (!IS_ERR_OR_NULL(s3c_intc[2]))
>                         if (s3c24xx_handle_intc(s3c_intc[2], regs, 64))
>                                 continue;

I just saw this in the pull request. I'm taking the pull request since
it's a bugfix and
the resulting code is technically correct, but I'd point out that this
is particularly
ugly. Any use of IS_ERR_OR_NULL() essentially means we have a misdefined
interface, and it's clear that this is one of them.

Nothing actually uses the return code of s3c24xx_init_intc(), so returning
NULL on error there and changing all the checks to that would be a much
more straightforward solution.

Any chance you could send a follow-up to do that?

      Arnd

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Jackie Liu <liu.yun@linux.dev>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
	 "moderated list:ARM/SAMSUNG EXYNOS ARM ARCHITECTURES"
	<linux-samsung-soc@vger.kernel.org>,
	 Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Jackie Liu <liuyun01@kylinos.cn>
Subject: Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
Date: Tue, 26 Oct 2021 17:10:39 +0200	[thread overview]
Message-ID: <CAK8P3a2AxmdhGKhGxfQetfzE0nKaaTRBmX=0OEPoaxkkZwABNg@mail.gmail.com> (raw)
In-Reply-To: <20210901123557.1043953-1-liu.yun@linux.dev>

On Wed, Sep 1, 2021 at 2:35 PM Jackie Liu <liu.yun@linux.dev> wrote:

> +               /* For platform based machines, neither ERR nor NULL can happen here.
> +                * The s3c24xx_handle_irq() will be set as IRQ handler iff this succeeds:
> +                *
> +                *    s3c_intc[0] = s3c24xx_init_intc()
> +                *
> +                * If this fails, the next calls to s3c24xx_init_intc() won't be executed.
> +                *
> +                * For DT machine, s3c_init_intc_of() could set the IRQ handler without
> +                * setting s3c_intc[0] only if it was called with num_ctrl=0. There is no
> +                * such code path, so again the s3c_intc[0] will have a valid pointer if
> +                * set_handle_irq() is called.
> +                *
> +                * Therefore in s3c24xx_handle_irq(), the s3c_intc[0] is always something.
> +                */
> +               if (s3c24xx_handle_intc(s3c_intc[0], regs, 0))
> +                       continue;
>
> -               if (s3c_intc[2])
> +               if (!IS_ERR_OR_NULL(s3c_intc[2]))
>                         if (s3c24xx_handle_intc(s3c_intc[2], regs, 64))
>                                 continue;

I just saw this in the pull request. I'm taking the pull request since
it's a bugfix and
the resulting code is technically correct, but I'd point out that this
is particularly
ugly. Any use of IS_ERR_OR_NULL() essentially means we have a misdefined
interface, and it's clear that this is one of them.

Nothing actually uses the return code of s3c24xx_init_intc(), so returning
NULL on error there and changing all the checks to that would be a much
more straightforward solution.

Any chance you could send a follow-up to do that?

      Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2021-10-26 15:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01 12:35 [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc() Jackie Liu
2021-09-01 12:35 ` Jackie Liu
2021-09-06 10:23 ` Jackie Liu
2021-09-06 10:23   ` Jackie Liu
2021-09-06 10:52   ` Krzysztof Kozlowski
2021-09-06 10:52     ` Krzysztof Kozlowski
2021-09-15  7:50 ` Krzysztof Kozlowski
2021-09-15  7:50   ` Krzysztof Kozlowski
2021-10-26 15:10 ` Arnd Bergmann [this message]
2021-10-26 15:10   ` Arnd Bergmann
2021-10-26 15:22   ` Krzysztof Kozlowski
2021-10-26 15:22     ` Krzysztof Kozlowski
2021-10-26 15:28     ` Arnd Bergmann
2021-10-26 15:28       ` Arnd Bergmann

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='CAK8P3a2AxmdhGKhGxfQetfzE0nKaaTRBmX=0OEPoaxkkZwABNg@mail.gmail.com' \
    --to=arnd@arndb.de \
    --cc=krzysztof.kozlowski@canonical.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=liu.yun@linux.dev \
    --cc=liuyun01@kylinos.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.