All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thermal: thermal_core: policy store via sysfs is broken
@ 2013-06-03 13:59 ` Shawn Guo
  0 siblings, 0 replies; 4+ messages in thread
From: Shawn Guo @ 2013-06-03 13:59 UTC (permalink / raw)
  To: linux-pm; +Cc: Zhang Rui, Eduardo Valentin, linux-arm-kernel, Shawn Guo

When function __find_governor() gets called from policy_store(), the
argument 'buf' has a '\n' character at the end.  This causes strnicmp()
mismatches all the time.  Consequently, policy_store() will always
return -EINVAL, and hence the policy store via sysfs will always fail
even when users store a correct policy name.

Fix the problem by using strncasecmp() for policy name matching in
__find_governor().

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/thermal/thermal_core.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index d755440..6ba869f 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -57,9 +57,10 @@ static struct thermal_governor *__find_governor(const char *name)
 {
 	struct thermal_governor *pos;
 
-	list_for_each_entry(pos, &thermal_governor_list, governor_list)
-		if (!strnicmp(name, pos->name, THERMAL_NAME_LENGTH))
+	list_for_each_entry(pos, &thermal_governor_list, governor_list) {
+		if (!strncasecmp(name, pos->name, strlen(pos->name)))
 			return pos;
+	}
 
 	return NULL;
 }
-- 
1.7.9.5



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

end of thread, other threads:[~2013-06-03 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-03 13:59 [PATCH] thermal: thermal_core: policy store via sysfs is broken Shawn Guo
2013-06-03 13:59 ` Shawn Guo
2013-06-03 14:59 ` Eduardo Valentin
2013-06-03 14:59   ` Eduardo Valentin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.