net: ll_temac: fix error checking of irq_of_parse_and_map()
Subsystems (5)
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.
--- 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
@@ -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
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 andplatform_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 <[email protected]>
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@@ -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 */
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 andplatform_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 <[email protected]>--- 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@@ -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 */
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 ofirq_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 andplatform_get_irq()returns negative error codes. We need to handle both cases appropriately.Fixes 8425c41d1ef7 ("net: ll_temac: Extend support to non-device-treeplatforms")
Signed-off-by Dan Carpenter <[email protected]>
Thanks,
Regards,
Harini
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 andplatform_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 <[email protected]>[...]
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