Skip to content

Commit 39cdf87

Browse files
Dan Carpenterrafaeljw
authored andcommitted
cpuidle: psci: Fix uninitialized variable in dt_idle_state_present()
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: 5836ebe ("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>
1 parent 5836ebe commit 39cdf87

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/cpuidle/cpuidle-psci.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,14 +440,13 @@ static struct faux_device_ops psci_cpuidle_ops = {
440440

441441
static bool __init dt_idle_state_present(void)
442442
{
443-
struct device_node *cpu_node __free(device_node);
444-
struct device_node *state_node __free(device_node);
445-
446-
cpu_node = of_cpu_device_node_get(cpumask_first(cpu_possible_mask));
443+
struct device_node *cpu_node __free(device_node) =
444+
of_cpu_device_node_get(cpumask_first(cpu_possible_mask));
447445
if (!cpu_node)
448446
return false;
449447

450-
state_node = of_get_cpu_state_node(cpu_node, 0);
448+
struct device_node *state_node __free(device_node) =
449+
of_get_cpu_state_node(cpu_node, 0);
451450
if (!state_node)
452451
return false;
453452

0 commit comments

Comments
 (0)