From: Nate Diller Date: Sun, 30 Oct 2005 23:02:24 +0000 (-0800) Subject: [PATCH] block cleanups: Fix iosched module refcount leak X-Git-Tag: v2.6.15-rc1~59^2~15^2~93 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ca7d93bb27876e5fd4ebfcb3b00627107bdad4d;p=linux-2.6 [PATCH] block cleanups: Fix iosched module refcount leak 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 Acked-by: Jens Axboe Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/block/elevator.c b/drivers/block/elevator.c index 3b652eba2d..36f1057084 100644 --- a/drivers/block/elevator.c +++ b/drivers/block/elevator.c @@ -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;