From 2ca7d93bb27876e5fd4ebfcb3b00627107bdad4d Mon Sep 17 00:00:00 2001 From: Nate Diller Date: Sun, 30 Oct 2005 15:02:24 -0800 Subject: [PATCH] [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 --- drivers/block/elevator.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- 2.39.5