Skip to content

Commit e4539eb

Browse files
gscuigregkh
authored andcommitted
remoteproc: sysmon: fix memory leak in qcom_add_sysmon_subdev()
[ 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>
1 parent 6a65f46 commit e4539eb

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/remoteproc/qcom_sysmon.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,9 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,
625625
if (sysmon->shutdown_irq != -ENODATA) {
626626
dev_err(sysmon->dev,
627627
"failed to retrieve shutdown-ack IRQ\n");
628-
return ERR_PTR(sysmon->shutdown_irq);
628+
ret = sysmon->shutdown_irq;
629+
kfree(sysmon);
630+
return ERR_PTR(ret);
629631
}
630632
} else {
631633
ret = devm_request_threaded_irq(sysmon->dev,
@@ -636,6 +638,7 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,
636638
if (ret) {
637639
dev_err(sysmon->dev,
638640
"failed to acquire shutdown-ack IRQ\n");
641+
kfree(sysmon);
639642
return ERR_PTR(ret);
640643
}
641644
}

0 commit comments

Comments
 (0)