Skip to content

Commit

Permalink
elv_unregister: fix possible crash on module unload
Browse files Browse the repository at this point in the history
An exiting task or process which didn't do I/O yet have no io context,
elv_unregister() should check it is not NULL.

Signed-off-by: Oleg Nesterov <[email protected]>
Acked-by: Jens Axboe <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Oleg Nesterov authored and gregkh committed Aug 22, 2006
1 parent 00a2b0f commit 2d8f613
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion block/elevator.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,8 @@ void elv_unregister(struct elevator_type *e)
read_lock(&tasklist_lock);
do_each_thread(g, p) {
task_lock(p);
e->ops.trim(p->io_context);
if (p->io_context)
e->ops.trim(p->io_context);
task_unlock(p);
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
Expand Down

0 comments on commit 2d8f613

Please sign in to comment.