diff mbox series

net: systemport: Add and correct check for platform_get_irq

Message ID 20230531091159.8933-1-jiasheng@iscas.ac.cn (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: systemport: Add and correct check for platform_get_irq | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 13 this patch: 13
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch warning WARNING: line length of 88 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jiasheng Jiang May 31, 2023, 9:11 a.m. UTC
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(-)

Comments

Justin Chen May 31, 2023, 10:42 p.m. UTC | #1
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.

Thanks,
Justin
diff mbox series

Patch

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;
 	}