mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: systemport: Add and correct check for platform_get_irq
@ 2023-05-31  9:11 Jiasheng Jiang
  2023-05-31 22:42 ` Justin Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Jiasheng Jiang @ 2023-05-31  9:11 UTC (permalink / raw)
  To: f.fainelli, davem, edumazet, kuba, pabeni, bcm-kernel-feedback-list
  Cc: netdev, linux-kernel, Jiasheng Jiang

Add the missing check for "priv->wol_irq".
Use "<" instead of "<=" to check the irqs since the platform_get_irq
returns non-zero IRQ number on success and negative error number on
failure, shown in `driver/base/platform.c`.

Fixes: 83e82f4c706b ("net: systemport: add Wake-on-LAN support")
Fixes: 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 38d0cdaf22a5..16c9c0be1a33 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -2535,7 +2535,7 @@ static int bcm_sysport_probe(struct platform_device *pdev)
 	} else {
 		priv->wol_irq = platform_get_irq(pdev, 1);
 	}
-	if (priv->irq0 <= 0 || (priv->irq1 <= 0 && !priv->is_lite)) {
+	if (priv->irq0 < 0 || (priv->irq1 < 0 && !priv->is_lite) || priv->wol_irq < 0) {
 		ret = -EINVAL;
 		goto err_free_netdev;
 	}
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [PATCH] net: systemport: Add and correct check for platform_get_irq
@ 2023-06-01  3:16 Jiasheng Jiang
  0 siblings, 0 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2023-06-01  3:16 UTC (permalink / raw)
  To: justin.chen, f.fainelli, davem, edumazet, kuba, pabeni,
	bcm-kernel-feedback-list
  Cc: netdev, linux-kernel, Jiasheng Jiang

On Thu, Jun 01, 2023 at 06:42:26AM +0800, Justin Chen wrote:
> On 5/31/23 2:11 AM, Jiasheng Jiang wrote:
>> Add the missing check for "priv->wol_irq".
>> Use "<" instead of "<=" to check the irqs since the platform_get_irq
>> returns non-zero IRQ number on success and negative error number on
>> failure, shown in `driver/base/platform.c`.
>> 
>> Fixes: 83e82f4c706b ("net: systemport: add Wake-on-LAN support")
>> Fixes: 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
>> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
>> ---
>>   drivers/net/ethernet/broadcom/bcmsysport.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
>> index 38d0cdaf22a5..16c9c0be1a33 100644
>> --- a/drivers/net/ethernet/broadcom/bcmsysport.c
>> +++ b/drivers/net/ethernet/broadcom/bcmsysport.c
>> @@ -2535,7 +2535,7 @@ static int bcm_sysport_probe(struct platform_device *pdev)
>>   	} else {
>>   		priv->wol_irq = platform_get_irq(pdev, 1);
>>   	}
>> -	if (priv->irq0 <= 0 || (priv->irq1 <= 0 && !priv->is_lite)) {
>> +	if (priv->irq0 < 0 || (priv->irq1 < 0 && !priv->is_lite) || priv->wol_irq < 0) {
>>   		ret = -EINVAL;
>>   		goto err_free_netdev;
>>   	}
> 
> wol_irq is optional so we don't want to error out. Guess we should 
> probably replace platform_get_irq with platform_get_irq_optional(). "<=" 
> is fine. As you mentioned, a non-zero is success, so zero is considered 
> invalid.

Yes, you are right.
I will submit a new patch that replace platform_get_irq with
platform_get_irq_optional.

Thanks,
Jiasheng


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

end of thread, other threads:[~2023-06-01  3:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31  9:11 [PATCH] net: systemport: Add and correct check for platform_get_irq Jiasheng Jiang
2023-05-31 22:42 ` Justin Chen
2023-06-01  3:16 Jiasheng Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®