]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cpuidle: qcom-spm: fix device and OF node leaks at probe
authorJohan Hovold <johan@kernel.org>
Mon, 8 Sep 2025 15:22:12 +0000 (17:22 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Oct 2025 09:56:28 +0000 (11:56 +0200)
[ Upstream commit cdc06f912670c8c199d5fa9e78b64b7ed8e871d0 ]

Make sure to drop the reference to the saw device taken by
of_find_device_by_node() after retrieving its driver data during
probe().

Also drop the reference to the CPU node sooner to avoid leaking it in
case there is no saw node or device.

Fixes: 60f3692b5f0b ("cpuidle: qcom_spm: Detach state machine from main SPM handling")
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/cpuidle/cpuidle-qcom-spm.c

index beedf22cbe78b21d3982065d89020e8f24cc363f..716474a793817a0b72ca9bed87c032b7fa137ab7 100644 (file)
@@ -97,20 +97,23 @@ static int spm_cpuidle_register(struct device *cpuidle_dev, int cpu)
                return -ENODEV;
 
        saw_node = of_parse_phandle(cpu_node, "qcom,saw", 0);
+       of_node_put(cpu_node);
        if (!saw_node)
                return -ENODEV;
 
        pdev = of_find_device_by_node(saw_node);
        of_node_put(saw_node);
-       of_node_put(cpu_node);
        if (!pdev)
                return -ENODEV;
 
        data = devm_kzalloc(cpuidle_dev, sizeof(*data), GFP_KERNEL);
-       if (!data)
+       if (!data) {
+               put_device(&pdev->dev);
                return -ENOMEM;
+       }
 
        data->spm = dev_get_drvdata(&pdev->dev);
+       put_device(&pdev->dev);
        if (!data->spm)
                return -EINVAL;