Skip to contentSkip to conversation

cpufreq: qoriq: Fix clk reference leak in get_bus_freq()

PATCH In review blaze 2 participants 2 messages Sep 9 CPU frequency scaling framework

lore
Share & tools
lore

blaze

author
#0 lore raw

PATCH 1/1 cpufreq: qoriq: Fix clk reference leak in get_bus_freq()

clk_get() acquires a reference to the clock which must be released with clk_put() when no longer needed. In get_bus_freq(), the clock reference obtained by clk_get() is used only to read the frequency via clk_get_rate(), but clk_put() is never called, causing a clock reference count leak on every invocation.

Fix this by calling clk_put() before returning the frequency.

Fixes 1b6f255990ae ("cpufreq: qoriq: Enhance the support of clock from DTS")
---
 drivers/cpufreq/qoriq-cpufreq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/qoriq-cpufreq.c +3 -1
index 0000000..1111111 100644
@@ -62,7 +62,9 @@ static u32 get_bus_freq(void)
 			       __func__, PTR_ERR(pltclk));
 		return PTR_ERR(pltclk);
 	}
 
-	return clk_get_rate(pltclk);
+	sysfreq = clk_get_rate(pltclk);
+	clk_put(pltclk);
+	return sysfreq;
 }
 

static struct qoriq_cpu_data *qoriq_cpu_data;
--
2.43.0

#1 lore raw

Hello,

Quoted 9 lines · blaze

clk_get() acquires a reference to the clock which must be released with clk_put() when no longer needed. In get_bus_freq(), the clock reference obtained by clk_get() is used only to read the frequency via clk_get_rate(), but clk_put() is never called, causing a clock reference count leak on every invocation.

Fix this by calling clk_put() before returning the frequency.

Fixes 1b6f255990ae ("cpufreq: qoriq: Enhance the support of clock from DTS")

I couldn't find this commit using either the commit ID or the subject.

git show 1b6f255990ae

fatal: ambiguous argument '1b6f255990ae': unknown revision or path not
...

drivers/cpufreq/qoriq-cpufreq.c

Quoted 7 lines
---
  drivers/cpufreq/qoriq-cpufreq.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/qoriq-cpufreq.c +0 -0
index 0000000..1111111 100644

May I know why the blob hash is 0000000..1111111? Is this patch just generated by AI tools?

Quoted 18 lines
drivers/cpufreq/qoriq-cpufreq.c +3 -1
@@ -62,7 +62,9 @@ static u32 get_bus_freq(void)
  			       __func__, PTR_ERR(pltclk));
  		return PTR_ERR(pltclk);
  	}
 
-	return clk_get_rate(pltclk);
+	sysfreq = clk_get_rate(pltclk);
+	clk_put(pltclk);
+	return sysfreq;
  }
 

static struct qoriq_cpu_data *qoriq_cpu_data;
--
2.43.0

Signature · 2 lines
Thx and BRs,
Zhongqiu Han