diff mbox series

remoteproc: sysmon: fix memory leak in qcom_add_sysmon_subdev()

Message ID 20221129105650.1539187-1-cuigaosheng1@huawei.com (mailing list archive)
State Accepted
Headers show
Series remoteproc: sysmon: fix memory leak in qcom_add_sysmon_subdev() | expand

Commit Message

cuigaosheng Nov. 29, 2022, 10:56 a.m. UTC
The kfree() should be called when of_irq_get_byname() fails or
devm_request_threaded_irq() fails in qcom_add_sysmon_subdev(),
otherwise there will be a memory leak, so add kfree() to fix it.

Fixes: 027045a6e2b7 ("remoteproc: qcom: Add shutdown-ack irq")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
 drivers/remoteproc/qcom_sysmon.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Bjorn Andersson Dec. 7, 2022, 3:53 p.m. UTC | #1
On Tue, 29 Nov 2022 18:56:50 +0800, Gaosheng Cui wrote:
> The kfree() should be called when of_irq_get_byname() fails or
> devm_request_threaded_irq() fails in qcom_add_sysmon_subdev(),
> otherwise there will be a memory leak, so add kfree() to fix it.
> 
> 

Applied, thanks!

[1/1] remoteproc: sysmon: fix memory leak in qcom_add_sysmon_subdev()
      commit: e01ce676aaef3b13d02343d7e70f9637d93a3367

Best regards,
diff mbox series

Patch

diff --git a/drivers/remoteproc/qcom_sysmon.c b/drivers/remoteproc/qcom_sysmon.c
index 57dde2a69b9d..15af52f8499e 100644
--- a/drivers/remoteproc/qcom_sysmon.c
+++ b/drivers/remoteproc/qcom_sysmon.c
@@ -652,7 +652,9 @@  struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,
 		if (sysmon->shutdown_irq != -ENODATA) {
 			dev_err(sysmon->dev,
 				"failed to retrieve shutdown-ack IRQ\n");
-			return ERR_PTR(sysmon->shutdown_irq);
+			ret = sysmon->shutdown_irq;
+			kfree(sysmon);
+			return ERR_PTR(ret);
 		}
 	} else {
 		ret = devm_request_threaded_irq(sysmon->dev,
@@ -663,6 +665,7 @@  struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,
 		if (ret) {
 			dev_err(sysmon->dev,
 				"failed to acquire shutdown-ack IRQ\n");
+			kfree(sysmon);
 			return ERR_PTR(ret);
 		}
 	}