[PATCH 2/3] Fix strstrip() abuse in elv_iosched_store()

From: KOSAKI Motohiro
Date: Fri Oct 02 2009 - 04:40:03 EST



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 <lizf@xxxxxxxxxxxxxx>
Cc: Jens Axboe <jens.axboe@xxxxxxxxxx>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx>
---
block/elevator.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

Index: b/block/elevator.c
===================================================================
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -1059,9 +1059,7 @@ ssize_t elv_iosched_store(struct request
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;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/