diff mbox series

[net] net: ll_temac: fix error checking of irq_of_parse_and_map()

Message ID 3d0aef75-06e0-45a5-a2a6-2cc4738d4143@moroto.mountain (mailing list archive)
State Accepted
Commit ef45e8400f5bb66b03cc949f76c80e2a118447de
Delegated to: Netdev Maintainers
Headers show
Series [net] net: ll_temac: fix error checking of irq_of_parse_and_map() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1357 this patch: 1357
netdev/cc_maintainers warning 1 maintainers not CCed: linux-arm-kernel@lists.infradead.org
netdev/build_clang success Errors and warnings before: 1351 this patch: 1351
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: 1380 this patch: 1380
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Dan Carpenter July 31, 2023, 7:42 a.m. UTC
Most kernel functions return negative error codes but some irq functions
return zero on error.  In this code irq_of_parse_and_map(), returns zero
and platform_get_irq() returns negative error codes.  We need to handle
both cases appropriately.

Fixes: 8425c41d1ef7 ("net: ll_temac: Extend support to non-device-tree platforms")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/net/ethernet/xilinx/ll_temac_main.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Esben Haabendal July 31, 2023, 8:02 a.m. UTC | #1
Dan Carpenter <dan.carpenter@linaro.org> writes:

> Most kernel functions return negative error codes but some irq functions
> return zero on error.  In this code irq_of_parse_and_map(), returns zero
> and platform_get_irq() returns negative error codes.  We need to handle
> both cases appropriately.
>
> Fixes: 8425c41d1ef7 ("net: ll_temac: Extend support to non-device-tree platforms")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Acked-by: Esben Haabendal <esben@geanix.com>

> ---
>  drivers/net/ethernet/xilinx/ll_temac_main.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
> index e0ac1bcd9925..49f303353ecb 100644
> --- a/drivers/net/ethernet/xilinx/ll_temac_main.c
> +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
> @@ -1567,12 +1567,16 @@ static int temac_probe(struct platform_device *pdev)
>  	}
>  
>  	/* Error handle returned DMA RX and TX interrupts */
> -	if (lp->rx_irq < 0)
> -		return dev_err_probe(&pdev->dev, lp->rx_irq,
> +	if (lp->rx_irq <= 0) {
> +		rc = lp->rx_irq ?: -EINVAL;
> +		return dev_err_probe(&pdev->dev, rc,
>  				     "could not get DMA RX irq\n");
> -	if (lp->tx_irq < 0)
> -		return dev_err_probe(&pdev->dev, lp->tx_irq,
> +	}
> +	if (lp->tx_irq <= 0) {
> +		rc = lp->tx_irq ?: -EINVAL;
> +		return dev_err_probe(&pdev->dev, rc,
>  				     "could not get DMA TX irq\n");
> +	}
>  
>  	if (temac_np) {
>  		/* Retrieve the MAC address */
Yang Yingliang July 31, 2023, 8:02 a.m. UTC | #2
Reviewed-by: Yang Yingliang <yangyingliang@huawei.com>

On 2023/7/31 15:42, Dan Carpenter wrote:
> Most kernel functions return negative error codes but some irq functions
> return zero on error.  In this code irq_of_parse_and_map(), returns zero
> and platform_get_irq() returns negative error codes.  We need to handle
> both cases appropriately.
>
> Fixes: 8425c41d1ef7 ("net: ll_temac: Extend support to non-device-tree platforms")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>   drivers/net/ethernet/xilinx/ll_temac_main.c | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
> index e0ac1bcd9925..49f303353ecb 100644
> --- a/drivers/net/ethernet/xilinx/ll_temac_main.c
> +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
> @@ -1567,12 +1567,16 @@ static int temac_probe(struct platform_device *pdev)
>   	}
>   
>   	/* Error handle returned DMA RX and TX interrupts */
> -	if (lp->rx_irq < 0)
> -		return dev_err_probe(&pdev->dev, lp->rx_irq,
> +	if (lp->rx_irq <= 0) {
> +		rc = lp->rx_irq ?: -EINVAL;
> +		return dev_err_probe(&pdev->dev, rc,
>   				     "could not get DMA RX irq\n");
> -	if (lp->tx_irq < 0)
> -		return dev_err_probe(&pdev->dev, lp->tx_irq,
> +	}
> +	if (lp->tx_irq <= 0) {
> +		rc = lp->tx_irq ?: -EINVAL;
> +		return dev_err_probe(&pdev->dev, rc,
>   				     "could not get DMA TX irq\n");
> +	}
>   
>   	if (temac_np) {
>   		/* Retrieve the MAC address */
Katakam, Harini July 31, 2023, 10:57 a.m. UTC | #3
> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@linaro.org>
> Sent: Monday, July 31, 2023 1:13 PM
> To: Esben Haabendal <esben@geanix.com>
> Cc: David S. Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; Simek, Michal <michal.simek@amd.com>; Katakam,
> Harini <harini.katakam@amd.com>; Haoyue Xu <xuhaoyue1@hisilicon.com>;
> huangjunxian <huangjunxian6@hisilicon.com>; Yang Yingliang
> <yangyingliang@huawei.com>; Rob Herring <robh@kernel.org>;
> netdev@vger.kernel.org; kernel-janitors@vger.kernel.org
> Subject: [PATCH net] net: ll_temac: fix error checking of
> irq_of_parse_and_map()
> 
> Most kernel functions return negative error codes but some irq functions
> return zero on error.  In this code irq_of_parse_and_map(), returns zero
> and platform_get_irq() returns negative error codes.  We need to handle
> both cases appropriately.
> 
> Fixes: 8425c41d1ef7 ("net: ll_temac: Extend support to non-device-tree
> platforms")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Thanks,
Reviewed-by: Harini Katakam <harini.katakam@amd.com>

Regards,
Harini
patchwork-bot+netdevbpf@kernel.org Aug. 1, 2023, 9:50 p.m. UTC | #4
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 31 Jul 2023 10:42:32 +0300 you wrote:
> Most kernel functions return negative error codes but some irq functions
> return zero on error.  In this code irq_of_parse_and_map(), returns zero
> and platform_get_irq() returns negative error codes.  We need to handle
> both cases appropriately.
> 
> Fixes: 8425c41d1ef7 ("net: ll_temac: Extend support to non-device-tree platforms")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> 
> [...]

Here is the summary with links:
  - [net] net: ll_temac: fix error checking of irq_of_parse_and_map()
    https://git.kernel.org/netdev/net/c/ef45e8400f5b

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index e0ac1bcd9925..49f303353ecb 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -1567,12 +1567,16 @@  static int temac_probe(struct platform_device *pdev)
 	}
 
 	/* Error handle returned DMA RX and TX interrupts */
-	if (lp->rx_irq < 0)
-		return dev_err_probe(&pdev->dev, lp->rx_irq,
+	if (lp->rx_irq <= 0) {
+		rc = lp->rx_irq ?: -EINVAL;
+		return dev_err_probe(&pdev->dev, rc,
 				     "could not get DMA RX irq\n");
-	if (lp->tx_irq < 0)
-		return dev_err_probe(&pdev->dev, lp->tx_irq,
+	}
+	if (lp->tx_irq <= 0) {
+		rc = lp->tx_irq ?: -EINVAL;
+		return dev_err_probe(&pdev->dev, rc,
 				     "could not get DMA TX irq\n");
+	}
 
 	if (temac_np) {
 		/* Retrieve the MAC address */