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 @@ -468,13 +468,10 @@ mtx_assert(&isrc_table_lock, MA_OWNED); - if (isrc->isrc_irq >= intr_nirq) - return (EINVAL); - if (irq_sources[isrc->isrc_irq] != isrc) - return (EINVAL); - - irq_sources[isrc->isrc_irq] = NULL; - isrc->isrc_irq = INTR_IRQ_INVALID; /* just to be safe */ + if (isrc->isrc_irq < intr_nirq) { + 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, @@ -482,8 +479,9 @@ * will ensure maximum separation of allocation order from release * order. */ - if (irq_next_free >= intr_nirq) - irq_next_free = 0; + if (irq_next_free >= intr_nirq) + irq_next_free = 0; + } return (0); } @@ -537,7 +535,11 @@ isrc_release_counters(isrc); error = isrc_free_irq(isrc); mtx_unlock(&isrc_table_lock); - return (error); + + if (error != 0) + return (error); + + return (intr_event_destroy(isrc->isrc_event)); } #ifdef SMP