Netdev List
 help / color / mirror / Atom feed
* [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
  0 siblings, 1 reply; 2+ 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] 2+ 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
  0 siblings, 0 replies; 2+ 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] 2+ messages in thread

end of thread, other threads:[~2026-06-03 20:30 UTC | newest]

Thread overview: 2+ 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox