Skip to content

Commit

Permalink
elv_iosched_store(): fix strstrip() misuse
Browse files Browse the repository at this point in the history
elv_iosched_store() ignore the return value of strstrip().  It makes small
inconsistent behavior.

This patch fixes it.

 <before>
 ====================================
 # cd /sys/block/{blockdev}/queue

 case1:
 # echo "anticipatory" > scheduler
 # cat scheduler
 noop [anticipatory] deadline cfq

 case2:
 # echo "anticipatory " > scheduler
 # cat scheduler
 noop [anticipatory] deadline cfq

 case3:
 # echo " anticipatory" > scheduler
 bash: echo: write error: Invalid argument

 <after>
 ====================================
 # cd /sys/block/{blockdev}/queue

 case1:
 # echo "anticipatory" > scheduler
 # cat scheduler
 noop [anticipatory] deadline cfq

 case2:
 # echo "anticipatory " > scheduler
 # cat scheduler
 noop [anticipatory] deadline cfq

 case3:
 # echo " anticipatory" > scheduler
 noop [anticipatory] deadline cfq

Cc: Li Zefan <[email protected]>
Cc: Jens Axboe <[email protected]>
Signed-off-by: KOSAKI Motohiro <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
kosaki authored and Jens Axboe committed Oct 9, 2009
1 parent 355b659 commit 8c27959
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions block/elevator.c
Original file line number Diff line number Diff line change
@@ -1059,9 +1059,7 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
return count;

strlcpy(elevator_name, name, sizeof(elevator_name));
strstrip(elevator_name);

e = elevator_get(elevator_name);
e = elevator_get(strstrip(elevator_name));
if (!e) {
printk(KERN_ERR "elevator: type %s not found\n", elevator_name);
return -EINVAL;

0 comments on commit 8c27959

Please sign in to comment.