Skip to content

Commit 2ca7d93

Browse files
Nate DillerLinus Torvalds
authored andcommitted
[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 <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>
1 parent 3fa63c7 commit 2ca7d93

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/block/elevator.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,10 @@ ssize_t elv_iosched_store(request_queue_t *q, const char *name, size_t count)
753753
return -EINVAL;
754754
}
755755

756-
if (!strcmp(elevator_name, q->elevator->elevator_type->elevator_name))
756+
if (!strcmp(elevator_name, q->elevator->elevator_type->elevator_name)) {
757+
elevator_put(e);
757758
return count;
759+
}
758760

759761
elevator_switch(q, e);
760762
return count;

0 commit comments

Comments
 (0)