]> err.no Git - linux-2.6/commitdiff
[PATCH] block cleanups: Fix iosched module refcount leak
authorNate Diller <nate@namesys.com>
Sun, 30 Oct 2005 23:02:24 +0000 (15:02 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 31 Oct 2005 01:37:20 +0000 (17:37 -0800)
If the requested I/O scheduler is already in place, elevator_switch simply
leaves the queue alone, and returns.  However, it forgets to call
elevator_put, so

'echo [current_sched] > /sys/block/[dev]/queue/scheduler'

will leak a reference, causing the current_sched module to be permanently
pinned in memory.

Signed-off-by: Nate Diller <nate@namesys.com>
Acked-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/block/elevator.c

index 3b652eba2d206c872e1e1c1b3ac6be1554a3ebd0..36f1057084b024bdc978db18d3b1fab43ecd3273 100644 (file)
@@ -753,8 +753,10 @@ ssize_t elv_iosched_store(request_queue_t *q, const char *name, size_t count)
                return -EINVAL;
        }
 
-       if (!strcmp(elevator_name, q->elevator->elevator_type->elevator_name))
+       if (!strcmp(elevator_name, q->elevator->elevator_type->elevator_name)) {
+               elevator_put(e);
                return count;
+       }
 
        elevator_switch(q, e);
        return count;