Skip to content

Commit b594521

Browse files
diandersandersson
authored andcommitted
kernel/cpu_pm: Fix uninitted local in cpu_pm
cpu_pm_notify() is basically a wrapper of notifier_call_chain(). notifier_call_chain() doesn't initialize *nr_calls to 0 before it starts incrementing it--presumably it's up to the callers to do this. Unfortunately the callers of cpu_pm_notify() don't init *nr_calls. This potentially means you could get too many or two few calls to CPU_PM_ENTER_FAILED or CPU_CLUSTER_PM_ENTER_FAILED depending on the luck of the stack. Let's fix this. Fixes: ab10023 ("cpu_pm: Add cpu power management notifiers") Cc: [email protected] Cc: Rafael J. Wysocki <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/20200504104917.v6.3.I2d44fc0053d019f239527a4e5829416714b7e299@changeid Signed-off-by: Bjorn Andersson <[email protected]>
1 parent c45def5 commit b594521

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/cpu_pm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_unregister_notifier);
8080
*/
8181
int cpu_pm_enter(void)
8282
{
83-
int nr_calls;
83+
int nr_calls = 0;
8484
int ret = 0;
8585

8686
ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls);
@@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_exit);
131131
*/
132132
int cpu_cluster_pm_enter(void)
133133
{
134-
int nr_calls;
134+
int nr_calls = 0;
135135
int ret = 0;
136136

137137
ret = cpu_pm_notify(CPU_CLUSTER_PM_ENTER, -1, &nr_calls);

0 commit comments

Comments
 (0)