From 7c0cdc61bc348e0a93c2c50a2a9341d9554619fb Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Tue, 1 Dec 2009 16:46:27 +0000 Subject: [PATCH] fix for race condition - IRQ can happen between clearing the endpoint of the handling process and before removing the hook. The handler function will panic then. --- kernel/system/do_exit.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/kernel/system/do_exit.c b/kernel/system/do_exit.c index 05200601b..d5f85fbed 100644 --- a/kernel/system/do_exit.c +++ b/kernel/system/do_exit.c @@ -56,6 +56,14 @@ register struct proc *rc; /* slot of process to clean up */ /* Don't clear if already cleared. */ if(isemptyp(rc)) return; + /* Check the table with IRQ hooks to see if hooks should be released. */ + for (i=0; i < NR_IRQ_HOOKS; i++) { + int proc; + if (rc->p_endpoint == irq_hooks[i].proc_nr_e) { + rm_irq_handler(&irq_hooks[i]); /* remove interrupt handler */ + irq_hooks[i].proc_nr_e = NONE; /* mark hook as free */ + } + } /* Remove the process' ability to send and receive messages */ clear_endpoint(rc); @@ -69,15 +77,6 @@ register struct proc *rc; /* slot of process to clean up */ */ RTS_LOCK_SETFLAGS(rc, RTS_SLOT_FREE); - /* Check the table with IRQ hooks to see if hooks should be released. */ - for (i=0; i < NR_IRQ_HOOKS; i++) { - int proc; - if (rc->p_endpoint == irq_hooks[i].proc_nr_e) { - rm_irq_handler(&irq_hooks[i]); /* remove interrupt handler */ - irq_hooks[i].proc_nr_e = NONE; /* mark hook as free */ - } - } - /* Release the process table slot. If this is a system process, also * release its privilege structure. Further cleanup is not needed at * this point. All important fields are reinitialized when the