[PATCH v4 2/4] firmware: qcom_scm: Clear scm pointer on probe failure

From: Maximilian Luz
Date: Sun May 28 2023 - 19:04:19 EST


When setting-up the IRQ goes wrong, the __scm pointer currently remains
set even though we fail to probe the driver successfully. Due to this,
access to __scm may go wrong since associated resources (clocks, ...)
have been released. Therefore, clear the __scm pointer when setting-up
the IRQ fails.

Fixes: 6bf325992236 ("firmware: qcom: scm: Add wait-queue handling logic")
Signed-off-by: Maximilian Luz <luzmaximilian@xxxxxxxxx>
---

Patch introduced in v4

---
drivers/firmware/qcom_scm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index fde33acd46b7..d0070b833889 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -1488,8 +1488,10 @@ static int qcom_scm_probe(struct platform_device *pdev)
} else {
ret = devm_request_threaded_irq(__scm->dev, irq, NULL, qcom_scm_irq_handler,
IRQF_ONESHOT, "qcom-scm", __scm);
- if (ret < 0)
+ if (ret < 0) {
+ __scm = NULL;
return dev_err_probe(scm->dev, ret, "Failed to request qcom-scm irq\n");
+ }
}

__get_convention();
--
2.40.1