* [PATCH next] cpuidle: psci: Fix uninitialized variable in dt_idle_state_present()
@ 2025-05-27 5:45 Dan Carpenter
2025-05-27 13:27 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-05-27 5:45 UTC (permalink / raw)
To: Sudeep Holla
Cc: Lorenzo Pieralisi, Ulf Hansson, Rafael J. Wysocki, Daniel Lezcano,
linux-pm, linux-arm-kernel, linux-kernel, kernel-janitors
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>
---
drivers/cpuidle/cpuidle-psci.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c
index 3c2756a539c4..4e1ba35deda9 100644
--- a/drivers/cpuidle/cpuidle-psci.c
+++ b/drivers/cpuidle/cpuidle-psci.c
@@ -456,14 +456,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;
--
2.47.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH next] cpuidle: psci: Fix uninitialized variable in dt_idle_state_present()
2025-05-27 5:45 [PATCH next] cpuidle: psci: Fix uninitialized variable in dt_idle_state_present() Dan Carpenter
@ 2025-05-27 13:27 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2025-05-27 13:27 UTC (permalink / raw)
To: Dan Carpenter
Cc: Sudeep Holla, Lorenzo Pieralisi, Ulf Hansson, Rafael J. Wysocki,
Daniel Lezcano, linux-pm, linux-arm-kernel, linux-kernel,
kernel-janitors
On Tue, May 27, 2025 at 7:45 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> 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>
> ---
> drivers/cpuidle/cpuidle-psci.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c
> index 3c2756a539c4..4e1ba35deda9 100644
> --- a/drivers/cpuidle/cpuidle-psci.c
> +++ b/drivers/cpuidle/cpuidle-psci.c
> @@ -456,14 +456,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;
>
> --
Applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-27 13:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27 5:45 [PATCH next] cpuidle: psci: Fix uninitialized variable in dt_idle_state_present() Dan Carpenter
2025-05-27 13:27 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).