linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ptp: ixp46x: Fix error handling in ptp_ixp_probe()
@ 2021-11-26  1:10 Tang Bin
  2021-11-26  1:26 ` Linus Walleij
  0 siblings, 1 reply; 6+ messages in thread
From: Tang Bin @ 2021-11-26  1:10 UTC (permalink / raw)
  To: davem, kuba, linus.walleij, arnd, wanjiabing
  Cc: netdev, linux-kernel, Tang Bin

In the function ptp_ixp_probe(), when get irq failed
after executing platform_get_irq(), the negative value
returned will not be detected here. So fix error handling
in this place.

Fixes: 9055a2f591629 ("ixp4xx_eth: make ptp support a platform driver")
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
---
 drivers/net/ethernet/xscale/ptp_ixp46x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/xscale/ptp_ixp46x.c b/drivers/net/ethernet/xscale/ptp_ixp46x.c
index 39234852e01b..c52e01d89e47 100644
--- a/drivers/net/ethernet/xscale/ptp_ixp46x.c
+++ b/drivers/net/ethernet/xscale/ptp_ixp46x.c
@@ -272,7 +272,7 @@ static int ptp_ixp_probe(struct platform_device *pdev)
 	ixp_clock.master_irq = platform_get_irq(pdev, 0);
 	ixp_clock.slave_irq = platform_get_irq(pdev, 1);
 	if (IS_ERR(ixp_clock.regs) ||
-	    !ixp_clock.master_irq || !ixp_clock.slave_irq)
+	    (ixp_clock.master_irq < 0) || (ixp_clock.slave_irq < 0))
 		return -ENXIO;
 
 	ixp_clock.caps = ptp_ixp_caps;
-- 
2.18.2




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

* Re: [PATCH] ptp: ixp46x: Fix error handling in ptp_ixp_probe()
  2021-11-26  1:10 [PATCH] ptp: ixp46x: Fix error handling in ptp_ixp_probe() Tang Bin
@ 2021-11-26  1:26 ` Linus Walleij
  2021-11-26  1:39   ` tangbin
  0 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2021-11-26  1:26 UTC (permalink / raw)
  To: Tang Bin; +Cc: davem, kuba, arnd, wanjiabing, netdev, linux-kernel

On Fri, Nov 26, 2021 at 2:10 AM Tang Bin <tangbin@cmss.chinamobile.com> wrote:

> In the function ptp_ixp_probe(), when get irq failed
> after executing platform_get_irq(), the negative value
> returned will not be detected here. So fix error handling
> in this place.
>
> Fixes: 9055a2f591629 ("ixp4xx_eth: make ptp support a platform driver")
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>

OK the intention is right but:

> -           !ixp_clock.master_irq || !ixp_clock.slave_irq)
> +           (ixp_clock.master_irq < 0) || (ixp_clock.slave_irq < 0))

Keep disallowing 0. Because that is not a valid IRQ.

... <= 0 ...

Yours,
Linus Walleij

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

* Re: [PATCH] ptp: ixp46x: Fix error handling in ptp_ixp_probe()
  2021-11-26  1:26 ` Linus Walleij
@ 2021-11-26  1:39   ` tangbin
  2021-11-26 23:09     ` Linus Walleij
  0 siblings, 1 reply; 6+ messages in thread
From: tangbin @ 2021-11-26  1:39 UTC (permalink / raw)
  To: Linus Walleij; +Cc: davem, kuba, arnd, wanjiabing, netdev, linux-kernel

Hi

On 2021/11/26 9:26, Linus Walleij wrote:
> On Fri, Nov 26, 2021 at 2:10 AM Tang Bin <tangbin@cmss.chinamobile.com> wrote:
>
>> In the function ptp_ixp_probe(), when get irq failed
>> after executing platform_get_irq(), the negative value
>> returned will not be detected here. So fix error handling
>> in this place.
>>
>> Fixes: 9055a2f591629 ("ixp4xx_eth: make ptp support a platform driver")
>> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> OK the intention is right but:
>
>> -           !ixp_clock.master_irq || !ixp_clock.slave_irq)
>> +           (ixp_clock.master_irq < 0) || (ixp_clock.slave_irq < 0))
> Keep disallowing 0. Because that is not a valid IRQ.
>
> ... <= 0 ...

Please look at the function platform_get_irq() in the file 
drivers/base/platform.c,

the example is :

     * int irq = platform_get_irq(pdev, 0);

     * if (irq < 0)

     *        return irq;

Thanks

Tang Bin




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

* Re: [PATCH] ptp: ixp46x: Fix error handling in ptp_ixp_probe()
  2021-11-26  1:39   ` tangbin
@ 2021-11-26 23:09     ` Linus Walleij
  0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2021-11-26 23:09 UTC (permalink / raw)
  To: tangbin; +Cc: davem, kuba, arnd, wanjiabing, netdev, linux-kernel

On Fri, Nov 26, 2021 at 2:40 AM tangbin <tangbin@cmss.chinamobile.com> wrote:
> On 2021/11/26 9:26, Linus Walleij wrote:
> > On Fri, Nov 26, 2021 at 2:10 AM Tang Bin <tangbin@cmss.chinamobile.com> wrote:
> >
> >> In the function ptp_ixp_probe(), when get irq failed
> >> after executing platform_get_irq(), the negative value
> >> returned will not be detected here. So fix error handling
> >> in this place.
> >>
> >> Fixes: 9055a2f591629 ("ixp4xx_eth: make ptp support a platform driver")
> >> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> > OK the intention is right but:
> >
> >> -           !ixp_clock.master_irq || !ixp_clock.slave_irq)
> >> +           (ixp_clock.master_irq < 0) || (ixp_clock.slave_irq < 0))
> > Keep disallowing 0. Because that is not a valid IRQ.
> >
> > ... <= 0 ...
>
> Please look at the function platform_get_irq() in the file
> drivers/base/platform.c,
>
> the example is :
>
>      * int irq = platform_get_irq(pdev, 0);
>
>      * if (irq < 0)
>
>      *        return irq;

In this case, reading the code is a bad idea. IRQ 0 is not valid,
and the fact that platform_get_irq() can return 0 does not make
it valid.

See:
https://lwn.net/Articles/470820/

Yours,
Linus Walleij

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

* Re: [PATCH] ptp: ixp46x: Fix error handling in ptp_ixp_probe()
  2021-11-25  7:54 Tang Bin
@ 2021-11-25 17:48 ` Jakub Kicinski
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2021-11-25 17:48 UTC (permalink / raw)
  To: Tang Bin; +Cc: davem, netdev, linux-kernel

On Thu, 25 Nov 2021 15:54:32 +0800 Tang Bin wrote:
> In the function ptp_ixp_probe(), when get irq failed
> after executing platform_get_irq(), the negative value
> returned will not be detected here. So fix error handling
> in this place.
> 
> Fixes: 9055a2f591629 ("ixp4xx_eth: make ptp support a platform driver")
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>

Please resend this and CC the right people.

./scripts/get_maintainer.pl

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

* [PATCH] ptp: ixp46x: Fix error handling in ptp_ixp_probe()
@ 2021-11-25  7:54 Tang Bin
  2021-11-25 17:48 ` Jakub Kicinski
  0 siblings, 1 reply; 6+ messages in thread
From: Tang Bin @ 2021-11-25  7:54 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, Tang Bin

In the function ptp_ixp_probe(), when get irq failed
after executing platform_get_irq(), the negative value
returned will not be detected here. So fix error handling
in this place.

Fixes: 9055a2f591629 ("ixp4xx_eth: make ptp support a platform driver")
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
---
 drivers/net/ethernet/xscale/ptp_ixp46x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/xscale/ptp_ixp46x.c b/drivers/net/ethernet/xscale/ptp_ixp46x.c
index 39234852e01b..c52e01d89e47 100644
--- a/drivers/net/ethernet/xscale/ptp_ixp46x.c
+++ b/drivers/net/ethernet/xscale/ptp_ixp46x.c
@@ -272,7 +272,7 @@ static int ptp_ixp_probe(struct platform_device *pdev)
 	ixp_clock.master_irq = platform_get_irq(pdev, 0);
 	ixp_clock.slave_irq = platform_get_irq(pdev, 1);
 	if (IS_ERR(ixp_clock.regs) ||
-	    !ixp_clock.master_irq || !ixp_clock.slave_irq)
+	    (ixp_clock.master_irq < 0) || (ixp_clock.slave_irq < 0))
 		return -ENXIO;
 
 	ixp_clock.caps = ptp_ixp_caps;
-- 
2.18.2




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

end of thread, other threads:[~2021-11-26 23:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26  1:10 [PATCH] ptp: ixp46x: Fix error handling in ptp_ixp_probe() Tang Bin
2021-11-26  1:26 ` Linus Walleij
2021-11-26  1:39   ` tangbin
2021-11-26 23:09     ` Linus Walleij
  -- strict thread matches above, loose matches on Subject: below --
2021-11-25  7:54 Tang Bin
2021-11-25 17:48 ` Jakub Kicinski

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