public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Hillf Danton <dhillf@gmail.com>
Cc: linux-kernel@vger.kernel.org, Rik van Riel <riel@redhat.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Mike Galbraith <efault@gmx.de>
Subject: Re: [PATCH] sched: fix strncmp operation
Date: Thu, 6 Jan 2011 15:47:57 -0800	[thread overview]
Message-ID: <20110106154757.75fb6b2a.akpm@linux-foundation.org> (raw)
In-Reply-To: <AANLkTinOPuYsVovrZpbuCCmG5deEyc8WgA_A1RJx_YK7@mail.gmail.com>

On Thu, 6 Jan 2011 20:58:12 +0800
Hillf Danton <dhillf@gmail.com> wrote:

> One of the operands, buf, is incorrect, since it is stripped and the
> correct address for subsequent string comparing could change if
> leading white spaces, if any, are removed from buf.
> 
> It is fixed by replacing buf with cmp.
> 
> Signed-off-by: Hillf Danton <dhillf@gmail.com>
> ---
> 
> --- a/kernel/sched.c	2010-11-01 19:54:12.000000000 +0800
> +++ b/kernel/sched.c	2011-01-06 20:52:02.000000000 +0800
> @@ -751,7 +751,7 @@ sched_feat_write(struct file *filp, cons
>  	buf[cnt] = 0;
>  	cmp = strstrip(buf);
> 
> -	if (strncmp(buf, "NO_", 3) == 0) {
> +	if (strncmp(cmp, "NO_", 3) == 0) {
>  		neg = 1;
>  		cmp += 3;
>  	}

Just remove the strstrip(), I'd say.  The kernel practically never
strips leading whitespace from sysfs input, so why do it here? 



  reply	other threads:[~2011-01-06 23:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-06 12:58 [PATCH] sched: fix strncmp operation Hillf Danton
2011-01-06 23:47 ` Andrew Morton [this message]
2011-01-08  4:14   ` Hillf Danton
2011-01-07 15:37 ` [tip:sched/urgent] sched: Fix " tip-bot for Hillf Danton

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=20110106154757.75fb6b2a.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=dhillf@gmail.com \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=riel@redhat.com \
    /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