Skip to contentSkip to conversation

block cleanups: Fix iosched module refcount leak

PATCH In review Nate Diller 2 participants 2 messages Sep 27, 2005 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 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.

This patchset is against 2.6.14-rc2-mm1, but should apply to anything recent.

NATE

drivers/block/elevator.c +3 -1
@@ -692,8 +692,10 @@ ssize_t elv_iosched_store(request_queue_
 		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;
#1 lore raw
Quoted 11 lines · Nate Diller

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.

This patchset is against 2.6.14-rc2-mm1, but should apply to anything recent.

Thanks, looks good.

Signature · 1 line
Jens Axboe