Thread (2 messages) 2 messages, 2 authors, 2020-01-20
STALE2334d

[PATCH v4] cpufreq: brcmstb-avs: fix imbalance of cpufreq policy refcount

From: <hidden>
Date: 2020-01-20 07:41:47
Also in: linux-pm
Subsystem: broadcom stb avs cpufreq driver, cpu frequency scaling framework, the rest · Maintainers: Markus Mayer, "Rafael J. Wysocki", Viresh Kumar, Linus Torvalds

From: chenqiwu <redacted>

brcm_avs_cpufreq_get() calls cpufreq_cpu_get() to get the cpufreq
policy, meanwhile, it also increments the kobject reference count
to mark it busy. However, a corresponding call of cpufreq_cpu_put()
is ignored to decrement the kobject reference count back, which may
lead to a potential stuck risk that the cpuhp thread deadly waits
for dropping of kobject refcount when cpufreq policy free.

With this patch, the cpuhp thread can be easily exercised by
attempting to force an unbind of the CPUfreq driver.

Signed-off-by: chenqiwu <redacted>
---
changes in v4:
 - Rewrit commit message.
 - Use cpufreq_cpu_get() and a corresponding cpufreq_cpu_put()
   instead of cpufreq_get_policy() for promoting efficiency.
---
 drivers/cpufreq/brcmstb-avs-cpufreq.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/brcmstb-avs-cpufreq.c b/drivers/cpufreq/brcmstb-avs-cpufreq.c
index 77b0e5d..0767206 100644
--- a/drivers/cpufreq/brcmstb-avs-cpufreq.c
+++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c
@@ -453,7 +453,13 @@ static bool brcm_avs_is_firmware_loaded(struct private_data *priv)
 static unsigned int brcm_avs_cpufreq_get(unsigned int cpu)
 {
 	struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
-	struct private_data *priv = policy->driver_data;
+	struct private_data *priv;
+
+	if (!policy)
+		return 0;
+
+	priv = policy->driver_data;
+	cpufreq_cpu_put(policy);
 
 	return brcm_avs_get_frequency(priv->base);
 }
-- 
1.9.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help