From patchwork Tue May 7 14:21:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 2535191 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A21CD3FC5A for ; Tue, 7 May 2013 14:21:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752718Ab3EGOVJ (ORCPT ); Tue, 7 May 2013 10:21:09 -0400 Received: from mga03.intel.com ([143.182.124.21]:9671 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752479Ab3EGOVI (ORCPT ); Tue, 7 May 2013 10:21:08 -0400 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga101.ch.intel.com with ESMTP; 07 May 2013 07:21:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,628,1363158000"; d="scan'208";a="238062602" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.173]) by AZSMGA002.ch.intel.com with ESMTP; 07 May 2013 07:21:05 -0700 Received: from andy by smile with local (Exim 4.80) (envelope-from ) id 1UZilJ-0003z1-IX; Tue, 07 May 2013 17:21:01 +0300 From: Andy Shevchenko To: Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCHv2] thermal: cut the spaces when user sets policy Date: Tue, 7 May 2013 17:21:00 +0300 Message-Id: <1367936460-15257-1-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 1.8.2.rc0.22.gb3600c3 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Setting policy results in invalid value error. % echo "step_wise" > policy % echo: write error: Invalid argument Need clean up of the buffer which "echo" may add based on the arguments, before comparing aganist list of governor names. Signed-off-by: Andy Shevchenko Reported-by: Srinivas Pandruvada --- In v2: - copy input string to a temporary buffer drivers/thermal/thermal_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index d755440..e256380 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -713,10 +714,13 @@ policy_store(struct device *dev, struct device_attribute *attr, int ret = -EINVAL; struct thermal_zone_device *tz = to_thermal_zone(dev); struct thermal_governor *gov; + char *name[THERMAL_NAME_LENGTH]; + + snprintf(name, sizeof(name), "%s", buf); mutex_lock(&thermal_governor_lock); - gov = __find_governor(buf); + gov = __find_governor(strim(name)); if (!gov) goto exit;