diff --git a/sys/kern/subr_intr.c b/sys/kern/subr_intr.c --- a/sys/kern/subr_intr.c +++ b/sys/kern/subr_intr.c @@ -415,6 +415,20 @@ return (EINVAL); } +/* + * Destroy interrupt event for interrupt source. + */ +static int +isrc_event_destroy(struct intr_irqsrc *isrc) +{ + int rc = intr_event_destroy(isrc->isrc_event); + + if (rc == 0) + isrc->isrc_event = NULL; + + return (rc); +} + /* * Alloc unique interrupt number (resource handle) for interrupt source. * @@ -467,12 +481,11 @@ mtx_assert(&isrc_table_lock, MA_OWNED); if (isrc->isrc_irq >= intr_nirq) - return (EINVAL); - if (irq_sources[isrc->isrc_irq] != isrc) - return (EINVAL); + return (0); - irq_sources[isrc->isrc_irq] = NULL; - isrc->isrc_irq = INTR_IRQ_INVALID; /* just to be safe */ + if (irq_sources[isrc->isrc_irq] == isrc) + irq_sources[isrc->isrc_irq] = NULL; + isrc->isrc_irq = INTR_IRQ_INVALID; /* mark removed */ /* * If we are recovering from the state irq_sources table is full, @@ -535,7 +548,11 @@ isrc_release_counters(isrc); error = isrc_free_irq(isrc); mtx_unlock(&isrc_table_lock); - return (error); + + if (error != 0) + return (error); + + return (isrc_event_destroy(isrc)); } #ifdef SMP @@ -702,24 +719,7 @@ return (0); } -#ifdef notyet -/* - * Destroy interrupt event for interrupt source. - */ -static void -isrc_event_destroy(struct intr_irqsrc *isrc) -{ - struct intr_event *ie; - - mtx_lock(&isrc_table_lock); - ie = isrc->isrc_event; - isrc->isrc_event = NULL; - mtx_unlock(&isrc_table_lock); - if (ie != NULL) - intr_event_destroy(ie); -} -#endif /* * Add handler to interrupt source. */