Skip to content

Commit

Permalink
sched: Fix string comparison in /proc/sched_features
Browse files Browse the repository at this point in the history
Fix incorrect handling of the following case:

 INTERACTIVE
 INTERACTIVE_SOMETHING_ELSE

The comparison only checks up to each element's length.

Changelog since v1:
 - Embellish using some Rostedtisms.
  [ mingo:                 ^^ == smaller and cleaner ]

Signed-off-by: Mathieu Desnoyers <[email protected]>
Reviewed-by: Steven Rostedt <[email protected]>
Cc: <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Tony Lindgren <[email protected]>
LKML-Reference: <20100913214700.GB16118@Krystal>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
compudj authored and Ingo Molnar committed Sep 14, 2010
1 parent 637bbdc commit 7740191
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ sched_feat_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *ppos)
{
char buf[64];
char *cmp = buf;
char *cmp;
int neg = 0;
int i;

Expand All @@ -732,16 +732,15 @@ sched_feat_write(struct file *filp, const char __user *ubuf,
return -EFAULT;

buf[cnt] = 0;
cmp = strstrip(buf);

if (strncmp(buf, "NO_", 3) == 0) {
neg = 1;
cmp += 3;
}

for (i = 0; sched_feat_names[i]; i++) {
int len = strlen(sched_feat_names[i]);

if (strncmp(cmp, sched_feat_names[i], len) == 0) {
if (strcmp(cmp, sched_feat_names[i]) == 0) {
if (neg)
sysctl_sched_features &= ~(1UL << i);
else
Expand Down

0 comments on commit 7740191

Please sign in to comment.