public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: Amit Daniel Kachhap <amit.kachhap@linaro.org>
Cc: linux-pm@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	lenb@kernel.org, linaro-dev@lists.linaro.org, patches@linaro.org
Subject: Re: [PATCH] thermal: Fix for setting the thermal zone mode to enable/disable
Date: Wed, 21 Mar 2012 15:13:57 +0100	[thread overview]
Message-ID: <20120321151357.53fb86e4@endymion.delvare> (raw)
In-Reply-To: <1332328201-21191-1-git-send-email-amit.kachhap@linaro.org>

On Wed, 21 Mar 2012 16:40:01 +0530, Amit Daniel Kachhap wrote:
> Basically without this patch changing the mode of thermal zone
> is not possible as wrong string size is passed to strncmp.

Actually it is possible,
$ echo -n disabled > mode
works fine. But it fails without the -n, your patch would fix that.

Acked-by: Jean Delvare <khali@linux-fr.org>

Note that a quick grep suggests that drivers/misc/ad525x_dpot.c,
security/selinux/hooks.c and arch/m68k/sun3/prom/console.c suffer from
the same issue, if you want to fix them too.

> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
> ---
>  drivers/thermal/thermal_sys.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> index 220ce7e..96da1af 100644
> --- a/drivers/thermal/thermal_sys.c
> +++ b/drivers/thermal/thermal_sys.c
> @@ -152,9 +152,9 @@ mode_store(struct device *dev, struct device_attribute *attr,
>  	if (!tz->ops->set_mode)
>  		return -EPERM;
>  
> -	if (!strncmp(buf, "enabled", sizeof("enabled")))
> +	if (!strncmp(buf, "enabled", sizeof("enabled") - 1))
>  		result = tz->ops->set_mode(tz, THERMAL_DEVICE_ENABLED);
> -	else if (!strncmp(buf, "disabled", sizeof("disabled")))
> +	else if (!strncmp(buf, "disabled", sizeof("disabled") - 1))
>  		result = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED);
>  	else
>  		result = -EINVAL;


-- 
Jean Delvare

  reply	other threads:[~2012-03-21 14:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-21 11:10 [PATCH] thermal: Fix for setting the thermal zone mode to enable/disable Amit Daniel Kachhap
2012-03-21 14:13 ` Jean Delvare [this message]
2012-03-21 14:47   ` Eric Paris
2012-03-21 15:18     ` Jean Delvare
2012-03-21 15:14   ` Geert Uytterhoeven
2012-03-21 15:27     ` Jean Delvare
2012-03-22  5:10   ` Amit Kachhap
2012-03-22  5:14 ` Len Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120321151357.53fb86e4@endymion.delvare \
    --to=khali@linux-fr.org \
    --cc=amit.kachhap@linaro.org \
    --cc=lenb@kernel.org \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=patches@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox