]> git.baikalelectronics.ru Git - kernel.git/commitdiff
soc: qcom: aoss: Fix refcount leak in qmp_cooling_devices_register
authorMiaoqian Lin <linmq006@gmail.com>
Mon, 6 Jun 2022 06:42:52 +0000 (10:42 +0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:17:35 +0000 (11:17 +0200)
[ Upstream commit 8353eae097b8b59f016f2882987efd1f1ca7560a ]

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: aae5cf3a96d0 ("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>
drivers/soc/qcom/qcom_aoss.c

index f16d6ec780644fc558576fa8c1c06d69c3eac8f7..bca98df55bc63b21d7508fdd30a978804607cb5a 100644 (file)
@@ -489,8 +489,10 @@ static int qmp_cooling_devices_register(struct qmp *qmp)
                        continue;
                ret = qmp_cooling_device_add(qmp, &qmp->cooling_devs[count++],
                                             child);
-               if (ret)
+               if (ret) {
+                       of_node_put(child);
                        goto unroll;
+               }
        }
 
        if (!count)