]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpuidle: psci: Fix uninitialized variable in dt_idle_state_present()
authorDan Carpenter <dan.carpenter@linaro.org>
Tue, 27 May 2025 05:45:21 +0000 (08:45 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 27 May 2025 13:26:50 +0000 (15:26 +0200)
If the first cpu_node = of_cpu_device_node_get() fails then the cleanup.h
code will try to free "state_node" but it hasn't been initialized yet.
Declare the device_nodes where they are initialized to fix this.

Fixes: 5836ebeb4a2b ("cpuidle: psci: Avoid initializing faux device if no DT idle states are present")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/aDVRcfU8O8sez1x7@stanley.mountain
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpuidle/cpuidle-psci.c

index 40f378c1dc9f3f4978074e70178a1fe88e363fe2..eef70b5259bc95659931d22e23c908499cf89dfa 100644 (file)
@@ -440,14 +440,13 @@ static struct faux_device_ops psci_cpuidle_ops = {
 
 static bool __init dt_idle_state_present(void)
 {
-       struct device_node *cpu_node __free(device_node);
-       struct device_node *state_node __free(device_node);
-
-       cpu_node = of_cpu_device_node_get(cpumask_first(cpu_possible_mask));
+       struct device_node *cpu_node __free(device_node) =
+                       of_cpu_device_node_get(cpumask_first(cpu_possible_mask));
        if (!cpu_node)
                return false;
 
-       state_node = of_get_cpu_state_node(cpu_node, 0);
+       struct device_node *state_node __free(device_node) =
+                       of_get_cpu_state_node(cpu_node, 0);
        if (!state_node)
                return false;