* [PATCH net] net: ibm: emac: fix unchecked platform_get_irq return value
@ 2026-06-01 4:02 Rosen Penev
2026-06-03 20:30 ` Jacob Keller
2026-06-04 2:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Rosen Penev @ 2026-06-01 4:02 UTC (permalink / raw)
To: netdev
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Shannon Nelson, Simon Horman, Rosen Penev, open list
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.
Fixes: a598f66d9169 ("net: ibm: emac: use platform_get_irq")
Assisted-by: Opencode:Big-Pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/net/ethernet/ibm/emac/core.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index e597e2ad434c..d2194b406c9e 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -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) {
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] net: ibm: emac: fix unchecked platform_get_irq return value
2026-06-01 4:02 [PATCH net] net: ibm: emac: fix unchecked platform_get_irq return value Rosen Penev
@ 2026-06-03 20:30 ` Jacob Keller
2026-06-04 2:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Jacob Keller @ 2026-06-03 20:30 UTC (permalink / raw)
To: Rosen Penev, netdev
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Shannon Nelson, Simon Horman, open list
On 5/31/2026 9:02 PM, Rosen Penev wrote:
> 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().
>
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.
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> Add the missing error check and goto err_gone.
>
> Fixes: a598f66d9169 ("net: ibm: emac: use platform_get_irq")
> Assisted-by: Opencode:Big-Pickle
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> drivers/net/ethernet/ibm/emac/core.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
> index e597e2ad434c..d2194b406c9e 100644
> --- a/drivers/net/ethernet/ibm/emac/core.c
> +++ b/drivers/net/ethernet/ibm/emac/core.c
> @@ -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) {
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] net: ibm: emac: fix unchecked platform_get_irq return value
2026-06-01 4:02 [PATCH net] net: ibm: emac: fix unchecked platform_get_irq return value Rosen Penev
2026-06-03 20:30 ` Jacob Keller
@ 2026-06-04 2:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-04 2:20 UTC (permalink / raw)
To: Rosen Penev
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, sln, horms,
linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 31 May 2026 21:02:00 -0700 you wrote:
> 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().
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-04 2:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-01 4:02 [PATCH net] net: ibm: emac: fix unchecked platform_get_irq return value Rosen Penev
2026-06-03 20:30 ` Jacob Keller
2026-06-04 2:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox