2023-09-01 08:45:53

by Jinjie Ruan

[permalink] [raw]
Subject: [PATCH] bus: omap_l3_smx: Add missing check for platform_get_irq()

This func misses checking for platform_get_irq()'s call and may passes the
negative error codes to request_irq(), which takes unsigned IRQ #,
causing it to fail with -EINVAL, overriding an original error code.

Fix this by stop calling request_irq() with invalid IRQ #s.

Fixes: 0ee7261c9212 ("drivers: bus: Move the OMAP interconnect driver to drivers/bus/")
Signed-off-by: Jinjie Ruan <[email protected]>
---
drivers/bus/omap_l3_smx.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/bus/omap_l3_smx.c b/drivers/bus/omap_l3_smx.c
index 31774648be9d..dd41b0d3cb1d 100644
--- a/drivers/bus/omap_l3_smx.c
+++ b/drivers/bus/omap_l3_smx.c
@@ -235,6 +235,11 @@ static int omap3_l3_probe(struct platform_device *pdev)
}

l3->debug_irq = platform_get_irq(pdev, 0);
+ if (l3->debug_irq < 0) {
+ ret = l3->debug_irq;
+ goto err1;
+ }
+
ret = request_irq(l3->debug_irq, omap3_l3_app_irq, IRQF_TRIGGER_RISING,
"l3-debug-irq", l3);
if (ret) {
@@ -243,6 +248,11 @@ static int omap3_l3_probe(struct platform_device *pdev)
}

l3->app_irq = platform_get_irq(pdev, 1);
+ if (l3->app_irq < 0) {
+ ret = l3->app_irq;
+ goto err2;
+ }
+
ret = request_irq(l3->app_irq, omap3_l3_app_irq, IRQF_TRIGGER_RISING,
"l3-app-irq", l3);
if (ret) {
--
2.34.1