[PATCH] thermal/drivers/qcom/lmh: Fix missing IRQ check in lmh_probe()

From: Zhang Shurong
Date: Sat Aug 26 2023 - 07:14:22 EST


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: 53bca371cdf7 ("thermal/drivers/qcom: Add support for LMh driver")
Signed-off-by: Zhang Shurong <zhang_shurong@xxxxxxxxxxx>
---
drivers/thermal/qcom/lmh.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/qcom/lmh.c b/drivers/thermal/qcom/lmh.c
index f6edb12ec004..38aedb9a7c67 100644
--- a/drivers/thermal/qcom/lmh.c
+++ b/drivers/thermal/qcom/lmh.c
@@ -198,7 +198,11 @@ static int lmh_probe(struct platform_device *pdev)
return ret;
}

- lmh_data->irq = platform_get_irq(pdev, 0);
+ ret = platform_get_irq(pdev, 0);
+ if (ret < 0)
+ return ret;
+
+ lmh_data->irq = ret;
lmh_data->domain = irq_domain_add_linear(np, 1, &lmh_irq_ops, lmh_data);
if (!lmh_data->domain) {
dev_err(dev, "Error adding irq_domain\n");
--
2.30.2