soc: qcom: aoss: Fix refcount leak in qmp_cooling_devices_register

[ Upstream commit e6e0951414a314e7db3e9e24fd924b3e15515288 ]

Every iteration of for_each_available_child_of_node() decrements
the reference count of the previous node.
When breaking early from a for_each_available_child_of_node() loop,
we need to explicitly call of_node_put() on the child node.
Add missing of_node_put() to avoid refcount leak.

Fixes: 05589b30b2 ("soc: qcom: Extend AOSS QMP driver to support resources that are used to wake up the SoC.")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220606064252.42595-1-linmq006@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Miaoqian Lin
2022-06-06 10:42:52 +04:00
committed by Greg Kroah-Hartman
parent 07aea6819d
commit 97713ed9b6

View File

@@ -493,9 +493,11 @@ static int qmp_cooling_devices_register(struct qmp *qmp)
continue; continue;
ret = qmp_cooling_device_add(qmp, &qmp->cooling_devs[count++], ret = qmp_cooling_device_add(qmp, &qmp->cooling_devs[count++],
child); child);
if (ret) if (ret) {
of_node_put(child);
goto unroll; goto unroll;
} }
}
if (!count) if (!count)
devm_kfree(qmp->dev, qmp->cooling_devs); devm_kfree(qmp->dev, qmp->cooling_devs);