Skip to content

Commit 7508215

Browse files
tmlemankartben
authored andcommitted
pm: Return false if pm_state_force fails to set state
Ensure `pm_state_force` returns `false` when it fails to retrieve or set the desired power state. This change improves error handling and ensures the function's behavior aligns with its intended purpose. Signed-off-by: Tomasz Leman <[email protected]>
1 parent ee874b3 commit 7508215

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

subsys/pm/pm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ bool pm_state_force(uint8_t cpu, const struct pm_state_info *info)
130130
"Invalid power state %d!", info->state);
131131

132132
info = pm_state_get(cpu, info->state, info->substate_id);
133+
if (info == NULL) {
134+
/* Return false if the state could not be retrieved */
135+
return false;
136+
}
133137

134138
key = k_spin_lock(&pm_forced_state_lock);
135139
z_cpus_pm_forced_state[cpu] = info;

0 commit comments

Comments
 (0)