Skip to content

Commit

Permalink
[PATCH] block cleanups: Fix iosched module refcount leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nate Diller authored and Linus Torvalds committed Oct 31, 2005
1 parent 3fa63c7 commit 2ca7d93
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/block/elevator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2ca7d93

Please sign in to comment.