Skip to contentSkip to conversation

cpufreq: remove redundant sprintf

PATCH New Kees Cook 1 participant 1 message May 4, 2011 CPU frequency scaling framework

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 cpufreq: remove redundant sprintf

Since format string handling is part of request_module, there is no need to construct the module name. As such, drop the redundant sprintf and heap usage.

---
 drivers/cpufreq/cpufreq.c |   19 ++++++-------------
 1 files changed, 6 insertions(+), 13 deletions(-)
drivers/cpufreq/cpufreq.c +6 -13
index 2dafc5c..95eb6cc 100644
@@ -411,21 +411,14 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
 		t = __find_governor(str_governor);
 
 		if (t == NULL) {
-			char *name = kasprintf(GFP_KERNEL, "cpufreq_%s",
-								str_governor);
+			int ret;
 
-			if (name) {
-				int ret;
+			mutex_unlock(&cpufreq_governor_mutex);
+			ret = request_module("cpufreq_%s", str_governor);
+			mutex_lock(&cpufreq_governor_mutex);
 
-				mutex_unlock(&cpufreq_governor_mutex);
-				ret = request_module("%s", name);
-				mutex_lock(&cpufreq_governor_mutex);
-
-				if (ret == 0)
-					t = __find_governor(str_governor);
-			}
-
-			kfree(name);
+			if (ret == 0)
+				t = __find_governor(str_governor);
 		}
 
 		if (t != NULL) {
Signature · 5 lines
1.7.4.1

-- 
Kees Cook
Ubuntu Security Team