The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 1/2] kernel/cpu_pm: Fix uninitted local in cpu_pm
@ 2020-04-17  0:31 Douglas Anderson
  2020-04-17  0:32 ` [PATCH v2 2/2] soc: qcom: rpmh-rsc: Remove the pm_lock Douglas Anderson
  0 siblings, 1 reply; 5+ messages in thread
From: Douglas Anderson @ 2020-04-17  0:31 UTC (permalink / raw)
  To: Greg Kroah-Hartman, rafael.j.wysocki, Andy Gross, Bjorn Andersson
  Cc: mkshah, evgreen, swboyd, mka, Douglas Anderson, Alexios Zavras,
	Allison Randal, Colin Cross, Kevin Hilman, Santosh Shilimkar,
	Thomas Gleixner, linux-kernel

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 <dianders@chromium.org>
---

Changes in v2:
- ("Fix uninitted local in cpu_pm") new for v2.

 kernel/cpu_pm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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.1.301.g55bc3eb7cb9-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-21  5:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-17  0:31 [PATCH v2 1/2] kernel/cpu_pm: Fix uninitted local in cpu_pm Douglas Anderson
2020-04-17  0:32 ` [PATCH v2 2/2] soc: qcom: rpmh-rsc: Remove the pm_lock Douglas Anderson
2020-04-17  8:07   ` Maulik Shah
2020-04-17 17:17     ` Doug Anderson
2020-04-21  5:58       ` Maulik Shah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox