Skip to content

Commit

Permalink
remoteproc: sysmon: fix memory leak in qcom_add_sysmon_subdev()
Browse files Browse the repository at this point in the history
[ Upstream commit e01ce67 ]

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: 027045a ("remoteproc: qcom: Add shutdown-ack irq")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20221129105650.1539187-1-cuigaosheng1@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
gscui authored and gregkh committed Dec 31, 2022
1 parent 4507c6a commit 131c0a3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/remoteproc/qcom_sysmon.c
Expand Up @@ -650,7 +650,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,
Expand All @@ -661,6 +663,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);
}
}
Expand Down

0 comments on commit 131c0a3

Please sign in to comment.