Commit b5945214 authored by Douglas Anderson's avatar Douglas Anderson Committed by Bjorn Andersson

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: ab10023e ("cpu_pm: Add cpu power management notifiers")
Cc: stable@vger.kernel.org
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20200504104917.v6.3.I2d44fc0053d019f239527a4e5829416714b7e299@changeidSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent c45def5d
...@@ -80,7 +80,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_unregister_notifier); ...@@ -80,7 +80,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_unregister_notifier);
*/ */
int cpu_pm_enter(void) int cpu_pm_enter(void)
{ {
int nr_calls; int nr_calls = 0;
int ret = 0; int ret = 0;
ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls); ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls);
...@@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_exit); ...@@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_exit);
*/ */
int cpu_cluster_pm_enter(void) int cpu_cluster_pm_enter(void)
{ {
int nr_calls; int nr_calls = 0;
int ret = 0; int ret = 0;
ret = cpu_pm_notify(CPU_CLUSTER_PM_ENTER, -1, &nr_calls); ret = cpu_pm_notify(CPU_CLUSTER_PM_ENTER, -1, &nr_calls);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment