Skip to contentSkip to conversation

net: ll_temac: fix error checking of irq_of_parse_and_map()

PATCH Applied Dan Carpenter 5 participants 5 messages Jul 31, 2023 – Aug 1, 2023

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/net/ethernet/xilinx/ll_temac_main.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/ethernet/xilinx/ll_temac_main.c +8 -4
index e0ac1bcd9925..49f303353ecb 100644
@@ -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 */
Signature · 1 line
2.39.2
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Dan Carpenter

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")
Quoted 29 lines
---
 drivers/net/ethernet/xilinx/ll_temac_main.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/ethernet/xilinx/ll_temac_main.c +8 -4
index e0ac1bcd9925..49f303353ecb 100644
@@ -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 */
Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 36 lines · Dan Carpenter

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")
---
  drivers/net/ethernet/xilinx/ll_temac_main.c | 12 ++++++++----
  1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/ethernet/xilinx/ll_temac_main.c +8 -4
index e0ac1bcd9925..49f303353ecb 100644
@@ -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 */
Reviewed-by on v1 1/1
#3 lore raw
In reply to Dan Carpenter
Quoted 16 lines

-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Monday, July 31, 2023 1:13 PM
To: Esben Haabendal <[email protected]>
Cc: David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Simek, Michal <[email protected]>; Katakam, Harini <[email protected]>; Haoyue Xu <[email protected]>; huangjunxian <[email protected]>; Yang Yingliang <[email protected]>; Rob Herring <[email protected]>; [email protected]; [email protected]
Subject: [PATCH net] net: ll_temac: fix error checking of irq_of_parse_and_map()

Quoted 8 lines

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

Thanks,

Regards,
Harini

#4 lore raw
In reply to Dan Carpenter
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · 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")

[...]

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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html