From: Oleg Nesterov Date: Tue, 22 Aug 2006 17:22:13 +0000 (+0400) Subject: elv_unregister: fix possible crash on module unload X-Git-Tag: v2.6.17.10~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bf7989b2326fecad1181985f5fa9860d50fb89f;p=thirdparty%2Fkernel%2Fstable.git elv_unregister: fix possible crash on module unload 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 Acked-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- diff --git a/block/elevator.c b/block/elevator.c index a0afdd317ceff..7be96bbe142c6 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -766,7 +766,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);