Hi,

On Fri, Apr 24, 2020 at 9:47 AM Douglas Anderson <diand...@chromium.org> wrote:
>
> 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: ab10023e0088 ("cpu_pm: Add cpu power management notifiers")
> Signed-off-by: Douglas Anderson <diand...@chromium.org>
> Reviewed-by: Stephen Boyd <swb...@chromium.org>
> ---
>
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2:
> - ("Fix uninitted local in cpu_pm") new for v2.
>
>  kernel/cpu_pm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

I'm hoping at least the first 3 patches in this series can land soon
so they can make it into v5.7.  The first 2 patches "Fix" a patch that
was introduced in v5.7 and the 3rd patch fixes a longstanding bug that
could also affect the same code.

Ideally all 3 patches could go through the Qualcomm tree to keep
things happy working there.  get_maintainer doesn't really identify an
owner for "kernel/cpu_pm.c" so maybe nobody would mind if patch 3
lands in the Qualcomm tree?  It looks like the most recent bugfixes to
it (back in 2017) were landed by Rafael, though.  Rafael: would you be
willing to Ack patch #3 for it to go in the Qualcomm tree?

---

If patches #4 and #5 look OK you could certainly also land them in
5.7, but the safer option for those two would be to target 5.8.

Thanks!

-Doug

>
> diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c
> index cbca6879ab7d..44a259338e33 100644
> --- a/kernel/cpu_pm.c
> +++ b/kernel/cpu_pm.c
> @@ -80,7 +80,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_unregister_notifier);
>   */
>  int cpu_pm_enter(void)
>  {
> -       int nr_calls;
> +       int nr_calls = 0;
>         int ret = 0;
>
>         ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls);
> @@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_exit);
>   */
>  int cpu_cluster_pm_enter(void)
>  {
> -       int nr_calls;
> +       int nr_calls = 0;
>         int ret = 0;
>
>         ret = cpu_pm_notify(CPU_CLUSTER_PM_ENTER, -1, &nr_calls);
> --
> 2.26.2.303.gf8c07b1a785-goog
>

Reply via email to