You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
soc: qcom: smsm: Fix refcount leak bugs in qcom_smsm_probe()
[ Upstream commitaf8f6f39b8] There are two refcount leak bugs in qcom_smsm_probe(): (1) The 'local_node' is escaped out from for_each_child_of_node() as the break of iteration, we should call of_node_put() for it in error path or when it is not used anymore. (2) The 'node' is escaped out from for_each_available_child_of_node() as the 'goto', we should call of_node_put() for it in goto target. Fixes:c97c4090ff("soc: qcom: smsm: Add driver for Qualcomm SMSM") Signed-off-by: Liang He <windhl@126.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Link: https://lore.kernel.org/r/20220721135217.1301039-1-windhl@126.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
1d312c12c9
commit
39781c98ad
@@ -511,7 +511,7 @@ static int qcom_smsm_probe(struct platform_device *pdev)
|
|||||||
for (id = 0; id < smsm->num_hosts; id++) {
|
for (id = 0; id < smsm->num_hosts; id++) {
|
||||||
ret = smsm_parse_ipc(smsm, id);
|
ret = smsm_parse_ipc(smsm, id);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
goto out_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Acquire the main SMSM state vector */
|
/* Acquire the main SMSM state vector */
|
||||||
@@ -519,13 +519,14 @@ static int qcom_smsm_probe(struct platform_device *pdev)
|
|||||||
smsm->num_entries * sizeof(u32));
|
smsm->num_entries * sizeof(u32));
|
||||||
if (ret < 0 && ret != -EEXIST) {
|
if (ret < 0 && ret != -EEXIST) {
|
||||||
dev_err(&pdev->dev, "unable to allocate shared state entry\n");
|
dev_err(&pdev->dev, "unable to allocate shared state entry\n");
|
||||||
return ret;
|
goto out_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
states = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_SMSM_SHARED_STATE, NULL);
|
states = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_SMSM_SHARED_STATE, NULL);
|
||||||
if (IS_ERR(states)) {
|
if (IS_ERR(states)) {
|
||||||
dev_err(&pdev->dev, "Unable to acquire shared state entry\n");
|
dev_err(&pdev->dev, "Unable to acquire shared state entry\n");
|
||||||
return PTR_ERR(states);
|
ret = PTR_ERR(states);
|
||||||
|
goto out_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Acquire the list of interrupt mask vectors */
|
/* Acquire the list of interrupt mask vectors */
|
||||||
@@ -533,13 +534,14 @@ static int qcom_smsm_probe(struct platform_device *pdev)
|
|||||||
ret = qcom_smem_alloc(QCOM_SMEM_HOST_ANY, SMEM_SMSM_CPU_INTR_MASK, size);
|
ret = qcom_smem_alloc(QCOM_SMEM_HOST_ANY, SMEM_SMSM_CPU_INTR_MASK, size);
|
||||||
if (ret < 0 && ret != -EEXIST) {
|
if (ret < 0 && ret != -EEXIST) {
|
||||||
dev_err(&pdev->dev, "unable to allocate smsm interrupt mask\n");
|
dev_err(&pdev->dev, "unable to allocate smsm interrupt mask\n");
|
||||||
return ret;
|
goto out_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
intr_mask = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_SMSM_CPU_INTR_MASK, NULL);
|
intr_mask = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_SMSM_CPU_INTR_MASK, NULL);
|
||||||
if (IS_ERR(intr_mask)) {
|
if (IS_ERR(intr_mask)) {
|
||||||
dev_err(&pdev->dev, "unable to acquire shared memory interrupt mask\n");
|
dev_err(&pdev->dev, "unable to acquire shared memory interrupt mask\n");
|
||||||
return PTR_ERR(intr_mask);
|
ret = PTR_ERR(intr_mask);
|
||||||
|
goto out_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup the reference to the local state bits */
|
/* Setup the reference to the local state bits */
|
||||||
@@ -550,7 +552,8 @@ static int qcom_smsm_probe(struct platform_device *pdev)
|
|||||||
smsm->state = qcom_smem_state_register(local_node, &smsm_state_ops, smsm);
|
smsm->state = qcom_smem_state_register(local_node, &smsm_state_ops, smsm);
|
||||||
if (IS_ERR(smsm->state)) {
|
if (IS_ERR(smsm->state)) {
|
||||||
dev_err(smsm->dev, "failed to register qcom_smem_state\n");
|
dev_err(smsm->dev, "failed to register qcom_smem_state\n");
|
||||||
return PTR_ERR(smsm->state);
|
ret = PTR_ERR(smsm->state);
|
||||||
|
goto out_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register handlers for remote processor entries of interest. */
|
/* Register handlers for remote processor entries of interest. */
|
||||||
@@ -580,16 +583,19 @@ static int qcom_smsm_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, smsm);
|
platform_set_drvdata(pdev, smsm);
|
||||||
|
of_node_put(local_node);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
unwind_interfaces:
|
unwind_interfaces:
|
||||||
|
of_node_put(node);
|
||||||
for (id = 0; id < smsm->num_entries; id++)
|
for (id = 0; id < smsm->num_entries; id++)
|
||||||
if (smsm->entries[id].domain)
|
if (smsm->entries[id].domain)
|
||||||
irq_domain_remove(smsm->entries[id].domain);
|
irq_domain_remove(smsm->entries[id].domain);
|
||||||
|
|
||||||
qcom_smem_state_unregister(smsm->state);
|
qcom_smem_state_unregister(smsm->state);
|
||||||
|
out_put:
|
||||||
|
of_node_put(local_node);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user