From 83d1f4557819d8277dab9dc0e44afc70c48125a7 Mon Sep 17 00:00:00 2001 From: Cristiano Giuffrida Date: Tue, 16 Mar 2010 10:20:36 +0000 Subject: [PATCH] Fixed a bug in interrupt handling code when removing a handler in case of a shared IRQ. --- kernel/system/do_irqctl.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/kernel/system/do_irqctl.c b/kernel/system/do_irqctl.c index 7656e2586..67d414802 100644 --- a/kernel/system/do_irqctl.c +++ b/kernel/system/do_irqctl.c @@ -81,22 +81,32 @@ PUBLIC int do_irqctl(struct proc * caller, message * m_ptr) } } - /* Find a free IRQ hook for this mapping. */ - hook_ptr = NULL; - for (irq_hook_id=0; irq_hook_idIRQ_HOOK_ID; if (notify_id > CHAR_BIT * sizeof(irq_id_t) - 1) return(EINVAL); + /* Try to find an existing mapping to override. */ + hook_ptr = NULL; + for (i=0; !hook_ptr && im_source + && irq_hooks[i].notify_id == notify_id) { + irq_hook_id = i; + hook_ptr = &irq_hooks[irq_hook_id]; /* existing hook */ + rm_irq_handler(&irq_hooks[irq_hook_id]); + } + } + + /* If there is nothing to override, find a free hook for this mapping. */ + for (i=0; !hook_ptr && iproc_nr_e = m_ptr->m_source; /* process to notify */ hook_ptr->notify_id = notify_id; /* identifier to pass */ -- 2.44.0