net: ibm: emac: fix unchecked platform_get_irq return value
Subsystems (2)
PATCH 1/1 net: ibm: emac: fix unchecked platform_get_irq return value
platform_get_irq() returns a negative errno on failure. Commit a598f66d9169 replaced irq_of_parse_and_map() (which returns 0 on failure) with platform_get_irq() but dropped the error check. Without it, a negative IRQ number is passed to devm_request_irq(), which fails with -EINVAL instead of propagating the real error from platform_get_irq().
Add the missing error check and goto err_gone.
--- drivers/net/ethernet/ibm/emac/core.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/ibm/emac/core.c +5 -0
@@ -3035,6 +3035,11 @@ static int emac_probe(struct platform_device *ofdev)/* Setup error IRQ handler */ dev->emac_irq =platform_get_irq (ofdev,0 ); +if (dev->emac_irq <0 ) { + err = dev->emac_irq; + goto err_gone; + } + err =devm_request_irq (&ofdev->dev, dev->emac_irq, emac_irq,0 ,"EMAC" , dev);if (err) {
Signature · 1 line
2.54.0
Quoted 7 lines · Rosen Penev
platform_get_irq()returns a negative errno on failure. Commita598f66d9169replacedirq_of_parse_and_map()(which returns 0 on failure) withplatform_get_irq()but dropped the error check. Without it, a negative IRQ number is passed todevm_request_irq(), which fails with-EINVALinstead of propagating the real error fromplatform_get_irq().
Yep, looking through devm_request_irq, it seems most likely to fail on irq_to_desc().
Definitely more explicit to correctly check the return value, though it seems like a relatively minor cleanup since we do fail almost immediately.
Quoted 25 lines
Add the missing error check and goto
err_gone.Fixes a598f66d9169 ("net: ibm: emac: use platform_get_irq")Assisted-by Opencode:Big-PickleSigned-off-by Rosen Penev <[email protected]>--- drivers/net/ethernet/ibm/emac/core.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/ethernet/ibm/emac/core.c +5
-0@@ -3035,6 +3035,11 @@ static int emac_probe(struct platform_device *ofdev)/* Setup error IRQ handler */ dev->emac_irq =platform_get_irq (ofdev,0 ); +if (dev->emac_irq <0 ) { + err = dev->emac_irq; + goto err_gone; + } + err =devm_request_irq (&ofdev->dev, dev->emac_irq, emac_irq,0 ,"EMAC" , dev);if (err) {
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Sun, 31 May 2026 21:02:00 -0700 you wrote:
platform_get_irq()returns a negative errno on failure. Commita598f66d9169replacedirq_of_parse_and_map()(which returns 0 on failure) withplatform_get_irq()but dropped the error check. Without it, a negative IRQ number is passed todevm_request_irq(), which fails with-EINVALinstead of propagating the real error fromplatform_get_irq().[...]
Here is the summary with links:
- [net] net: ibm: emac: fix unchecked platform_get_irq return value
https://git.kernel.org/netdev/net-next/c/1681cb1bde05
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html