All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
@ 2021-09-01 12:35 ` Jackie Liu
  0 siblings, 0 replies; 14+ messages in thread
From: Jackie Liu @ 2021-09-01 12:35 UTC (permalink / raw)
  To: krzysztof.kozlowski
  Cc: linux-samsung-soc, linux-arm-kernel, liu.yun, liuyun01

From: Jackie Liu <liuyun01@kylinos.cn>

The s3c24xx_init_intc() returns an error pointer upon failure, not NULL.
let's add an error pointer check in s3c24xx_handle_irq.

s3c_intc[0] is not NULL or ERR, we can simplify the code.

Fixes: 1f629b7a3ced ("ARM: S3C24XX: transform irq handling into a declarative form")
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 arch/arm/mach-s3c/irq-s3c24xx.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-s3c/irq-s3c24xx.c b/arch/arm/mach-s3c/irq-s3c24xx.c
index 0c631c14a817..df471d322493 100644
--- a/arch/arm/mach-s3c/irq-s3c24xx.c
+++ b/arch/arm/mach-s3c/irq-s3c24xx.c
@@ -362,11 +362,24 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc,
 static asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs)
 {
 	do {
-		if (likely(s3c_intc[0]))
-			if (s3c24xx_handle_intc(s3c_intc[0], regs, 0))
-				continue;
+		/* 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;
 
-- 
2.25.1


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

* [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
@ 2021-09-01 12:35 ` Jackie Liu
  0 siblings, 0 replies; 14+ messages in thread
From: Jackie Liu @ 2021-09-01 12:35 UTC (permalink / raw)
  To: krzysztof.kozlowski
  Cc: linux-samsung-soc, linux-arm-kernel, liu.yun, liuyun01

From: Jackie Liu <liuyun01@kylinos.cn>

The s3c24xx_init_intc() returns an error pointer upon failure, not NULL.
let's add an error pointer check in s3c24xx_handle_irq.

s3c_intc[0] is not NULL or ERR, we can simplify the code.

Fixes: 1f629b7a3ced ("ARM: S3C24XX: transform irq handling into a declarative form")
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 arch/arm/mach-s3c/irq-s3c24xx.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-s3c/irq-s3c24xx.c b/arch/arm/mach-s3c/irq-s3c24xx.c
index 0c631c14a817..df471d322493 100644
--- a/arch/arm/mach-s3c/irq-s3c24xx.c
+++ b/arch/arm/mach-s3c/irq-s3c24xx.c
@@ -362,11 +362,24 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc,
 static asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs)
 {
 	do {
-		if (likely(s3c_intc[0]))
-			if (s3c24xx_handle_intc(s3c_intc[0], regs, 0))
-				continue;
+		/* 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;
 
-- 
2.25.1


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

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

* Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
  2021-09-01 12:35 ` Jackie Liu
@ 2021-09-06 10:23   ` Jackie Liu
  -1 siblings, 0 replies; 14+ messages in thread
From: Jackie Liu @ 2021-09-06 10:23 UTC (permalink / raw)
  To: krzysztof.kozlowski; +Cc: linux-samsung-soc, linux-arm-kernel, liuyun01

Hi, krzysztof. Any suggestion?

--
BR, Jackie Liu

在 2021/9/1 下午8:35, Jackie Liu 写道:
> From: Jackie Liu <liuyun01@kylinos.cn>
> 
> The s3c24xx_init_intc() returns an error pointer upon failure, not NULL.
> let's add an error pointer check in s3c24xx_handle_irq.
> 
> s3c_intc[0] is not NULL or ERR, we can simplify the code.
> 
> Fixes: 1f629b7a3ced ("ARM: S3C24XX: transform irq handling into a declarative form")
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---
>   arch/arm/mach-s3c/irq-s3c24xx.c | 21 +++++++++++++++++----
>   1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-s3c/irq-s3c24xx.c b/arch/arm/mach-s3c/irq-s3c24xx.c
> index 0c631c14a817..df471d322493 100644
> --- a/arch/arm/mach-s3c/irq-s3c24xx.c
> +++ b/arch/arm/mach-s3c/irq-s3c24xx.c
> @@ -362,11 +362,24 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc,
>   static asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs)
>   {
>   	do {
> -		if (likely(s3c_intc[0]))
> -			if (s3c24xx_handle_intc(s3c_intc[0], regs, 0))
> -				continue;
> +		/* 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;
>   
> 

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

* Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
@ 2021-09-06 10:23   ` Jackie Liu
  0 siblings, 0 replies; 14+ messages in thread
From: Jackie Liu @ 2021-09-06 10:23 UTC (permalink / raw)
  To: krzysztof.kozlowski; +Cc: linux-samsung-soc, linux-arm-kernel, liuyun01

Hi, krzysztof. Any suggestion?

--
BR, Jackie Liu

在 2021/9/1 下午8:35, Jackie Liu 写道:
> From: Jackie Liu <liuyun01@kylinos.cn>
> 
> The s3c24xx_init_intc() returns an error pointer upon failure, not NULL.
> let's add an error pointer check in s3c24xx_handle_irq.
> 
> s3c_intc[0] is not NULL or ERR, we can simplify the code.
> 
> Fixes: 1f629b7a3ced ("ARM: S3C24XX: transform irq handling into a declarative form")
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---
>   arch/arm/mach-s3c/irq-s3c24xx.c | 21 +++++++++++++++++----
>   1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-s3c/irq-s3c24xx.c b/arch/arm/mach-s3c/irq-s3c24xx.c
> index 0c631c14a817..df471d322493 100644
> --- a/arch/arm/mach-s3c/irq-s3c24xx.c
> +++ b/arch/arm/mach-s3c/irq-s3c24xx.c
> @@ -362,11 +362,24 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc,
>   static asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs)
>   {
>   	do {
> -		if (likely(s3c_intc[0]))
> -			if (s3c24xx_handle_intc(s3c_intc[0], regs, 0))
> -				continue;
> +		/* 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;
>   
> 

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

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

* Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
  2021-09-06 10:23   ` Jackie Liu
@ 2021-09-06 10:52     ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 14+ messages in thread
From: Krzysztof Kozlowski @ 2021-09-06 10:52 UTC (permalink / raw)
  To: Jackie Liu; +Cc: linux-samsung-soc, linux-arm-kernel, liuyun01

On 06/09/2021 12:23, Jackie Liu wrote:
> Hi, krzysztof. Any suggestion?
> 

No, looks good, but it's a merge window time so this will wait.


Best regards,
Krzysztof

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

* Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
@ 2021-09-06 10:52     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 14+ messages in thread
From: Krzysztof Kozlowski @ 2021-09-06 10:52 UTC (permalink / raw)
  To: Jackie Liu; +Cc: linux-samsung-soc, linux-arm-kernel, liuyun01

On 06/09/2021 12:23, Jackie Liu wrote:
> Hi, krzysztof. Any suggestion?
> 

No, looks good, but it's a merge window time so this will wait.


Best regards,
Krzysztof

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

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

* Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
  2021-09-01 12:35 ` Jackie Liu
@ 2021-09-15  7:50   ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 14+ messages in thread
From: Krzysztof Kozlowski @ 2021-09-15  7:50 UTC (permalink / raw)
  To: Jackie Liu
  Cc: Krzysztof Kozlowski, linux-samsung-soc, linux-arm-kernel, liuyun01

On Wed, 1 Sep 2021 20:35:57 +0800, Jackie Liu wrote:
> From: Jackie Liu <liuyun01@kylinos.cn>
> 
> The s3c24xx_init_intc() returns an error pointer upon failure, not NULL.
> let's add an error pointer check in s3c24xx_handle_irq.
> 
> s3c_intc[0] is not NULL or ERR, we can simplify the code.
> 
> [...]

Applied, thanks!

[1/1] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
      commit: 2aa717473ce96c93ae43a5dc8c23cedc8ce7dd9f

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

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

* Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
@ 2021-09-15  7:50   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 14+ messages in thread
From: Krzysztof Kozlowski @ 2021-09-15  7:50 UTC (permalink / raw)
  To: Jackie Liu
  Cc: Krzysztof Kozlowski, linux-samsung-soc, linux-arm-kernel, liuyun01

On Wed, 1 Sep 2021 20:35:57 +0800, Jackie Liu wrote:
> From: Jackie Liu <liuyun01@kylinos.cn>
> 
> The s3c24xx_init_intc() returns an error pointer upon failure, not NULL.
> let's add an error pointer check in s3c24xx_handle_irq.
> 
> s3c_intc[0] is not NULL or ERR, we can simplify the code.
> 
> [...]

Applied, thanks!

[1/1] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
      commit: 2aa717473ce96c93ae43a5dc8c23cedc8ce7dd9f

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

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

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

* Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
  2021-09-01 12:35 ` Jackie Liu
@ 2021-10-26 15:10   ` Arnd Bergmann
  -1 siblings, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2021-10-26 15:10 UTC (permalink / raw)
  To: Jackie Liu
  Cc: Krzysztof Kozlowski,
	moderated list:ARM/SAMSUNG EXYNOS ARM ARCHITECTURES, Linux ARM,
	Jackie Liu

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

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

* Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
@ 2021-10-26 15:10   ` Arnd Bergmann
  0 siblings, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2021-10-26 15:10 UTC (permalink / raw)
  To: Jackie Liu
  Cc: Krzysztof Kozlowski,
	moderated list:ARM/SAMSUNG EXYNOS ARM ARCHITECTURES, Linux ARM,
	Jackie Liu

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

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

* Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
  2021-10-26 15:10   ` Arnd Bergmann
@ 2021-10-26 15:22     ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 14+ messages in thread
From: Krzysztof Kozlowski @ 2021-10-26 15:22 UTC (permalink / raw)
  To: Arnd Bergmann, Jackie Liu
  Cc: moderated list:ARM/SAMSUNG EXYNOS ARM ARCHITECTURES, Linux ARM,
	Jackie Liu

On 26/10/2021 17:10, Arnd Bergmann wrote:
> 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.

Yes, that's the case.

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

I can work on this but you know this is a legacy platform and none of us
can test it?


Best regards,
Krzysztof

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

* Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
@ 2021-10-26 15:22     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 14+ messages in thread
From: Krzysztof Kozlowski @ 2021-10-26 15:22 UTC (permalink / raw)
  To: Arnd Bergmann, Jackie Liu
  Cc: moderated list:ARM/SAMSUNG EXYNOS ARM ARCHITECTURES, Linux ARM,
	Jackie Liu

On 26/10/2021 17:10, Arnd Bergmann wrote:
> 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.

Yes, that's the case.

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

I can work on this but you know this is a legacy platform and none of us
can test it?


Best regards,
Krzysztof

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

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

* Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
  2021-10-26 15:22     ` Krzysztof Kozlowski
@ 2021-10-26 15:28       ` Arnd Bergmann
  -1 siblings, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2021-10-26 15:28 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Arnd Bergmann, Jackie Liu,
	moderated list:ARM/SAMSUNG EXYNOS ARM ARCHITECTURES, Linux ARM,
	Jackie Liu

On Tue, Oct 26, 2021 at 5:22 PM Krzysztof Kozlowski
<krzysztof.kozlowski@canonical.com> wrote:
> On 26/10/2021 17:10, Arnd Bergmann wrote:
> > On Wed, Sep 1, 2021 at 2:35 PM Jackie Liu <liu.yun@linux.dev> wrote:
...
> > 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?
>
> I can work on this but you know this is a legacy platform and none of us
> can test it?

Sure. I was actually hoping for Jackie to send you that follow-up.

      Arnd

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

* Re: [PATCH v2] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
@ 2021-10-26 15:28       ` Arnd Bergmann
  0 siblings, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2021-10-26 15:28 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Arnd Bergmann, Jackie Liu,
	moderated list:ARM/SAMSUNG EXYNOS ARM ARCHITECTURES, Linux ARM,
	Jackie Liu

On Tue, Oct 26, 2021 at 5:22 PM Krzysztof Kozlowski
<krzysztof.kozlowski@canonical.com> wrote:
> On 26/10/2021 17:10, Arnd Bergmann wrote:
> > On Wed, Sep 1, 2021 at 2:35 PM Jackie Liu <liu.yun@linux.dev> wrote:
...
> > 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?
>
> I can work on this but you know this is a legacy platform and none of us
> can test it?

Sure. I was actually hoping for Jackie to send you that follow-up.

      Arnd

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

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

end of thread, other threads:[~2021-10-26 15:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.