Skip to contentSkip to conversation

net: ibm: emac: mal: fix unchecked platform_get_irq return values

PATCH Superseded Rosen Penev 2 participants 2 messages Jun 1 – Jun 3

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ibm: emac: mal: fix unchecked platform_get_irq return values

platform_get_irq() returns a negative errno on failure. Commit c4f5d0454cab5 moved the platform_get_irq() calls and explicitly removed the error checks that were previously present, claiming devm_request_irq() can handle it. However, a negative IRQ number passed to devm_request_irq() fails with -EINVAL instead of propagating the real error from platform_get_irq().

Restore the missing error checks with proper errno propagation.

Fixes c4f5d0454cab5 ("net: ibm: emac: mal: move irq maps down")
Assisted-by Opencode:Big-Pickle
---
 drivers/net/ethernet/ibm/emac/mal.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/ethernet/ibm/emac/mal.c +11 -0
index 7d70056e9008..63a7a32aaf72 100644
@@ -635,6 +635,12 @@ static int mal_probe(struct platform_device *ofdev)
 	mal->txeob_irq = platform_get_irq(ofdev, 0);
 	mal->rxeob_irq = platform_get_irq(ofdev, 1);
 	mal->serr_irq = platform_get_irq(ofdev, 2);
+	if (mal->txeob_irq < 0 || mal->rxeob_irq < 0 || mal->serr_irq < 0) {
+		err = mal->txeob_irq < 0 ? mal->txeob_irq :
+		      mal->rxeob_irq < 0 ? mal->rxeob_irq : mal->serr_irq;
+		dev_err_probe(&ofdev->dev, err, "failed to get IRQ\n");
+		goto fail2;
+	}
 
 	if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) {
 		mal->txde_irq = mal->rxde_irq = mal->serr_irq;
@@ -643,6 +649,11 @@ static int mal_probe(struct platform_device *ofdev)
 	} else {
 		mal->txde_irq = platform_get_irq(ofdev, 3);
 		mal->rxde_irq = platform_get_irq(ofdev, 4);
+		if (mal->txde_irq < 0 || mal->rxde_irq < 0) {
+			err = mal->txde_irq < 0 ? mal->txde_irq : mal->rxde_irq;
+			dev_err_probe(&ofdev->dev, err, "failed to get IRQ\n");
+			goto fail2;
+		}
 		irqflags = 0;
 		hdlr_serr = mal_serr;
 		hdlr_txde = mal_txde;
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Rosen Penev

platform_get_irq() returns a negative errno on failure. Commit c4f5d0454cab5 moved the platform_get_irq() calls and explicitly removed the error checks that were previously present, claiming devm_request_irq() can handle it. However, a negative IRQ number passed to devm_request_irq() fails with -EINVAL instead of propagating the real error from platform_get_irq().

Quoted 6 lines

Restore the missing error checks with proper errno propagation.

Fixes c4f5d0454cab5 ("net: ibm: emac: mal: move irq maps down")
Assisted-by Opencode:Big-Pickle

---

Quoted 32 lines
 drivers/net/ethernet/ibm/emac/mal.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/ethernet/ibm/emac/mal.c +11 -0
index 7d70056e9008..63a7a32aaf72 100644
@@ -635,6 +635,12 @@ static int mal_probe(struct platform_device *ofdev)
 	mal->txeob_irq = platform_get_irq(ofdev, 0);
 	mal->rxeob_irq = platform_get_irq(ofdev, 1);
 	mal->serr_irq = platform_get_irq(ofdev, 2);
+	if (mal->txeob_irq < 0 || mal->rxeob_irq < 0 || mal->serr_irq < 0) {
+		err = mal->txeob_irq < 0 ? mal->txeob_irq :
+		      mal->rxeob_irq < 0 ? mal->rxeob_irq : mal->serr_irq;
+		dev_err_probe(&ofdev->dev, err, "failed to get IRQ\n");
+		goto fail2;
+	}
 
 	if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) {
 		mal->txde_irq = mal->rxde_irq = mal->serr_irq;
@@ -643,6 +649,11 @@ static int mal_probe(struct platform_device *ofdev)
 	} else {
 		mal->txde_irq = platform_get_irq(ofdev, 3);
 		mal->rxde_irq = platform_get_irq(ofdev, 4);
+		if (mal->txde_irq < 0 || mal->rxde_irq < 0) {
+			err = mal->txde_irq < 0 ? mal->txde_irq : mal->rxde_irq;
+			dev_err_probe(&ofdev->dev, err, "failed to get IRQ\n");
+			goto fail2;
+		}
 		irqflags = 0;
 		hdlr_serr = mal_serr;
 		hdlr_txde = mal_txde;