kernel: Check interrupt vector isn't assigned to a CPU on free.

If the vector is assigned to a CPU it means that the assignment
structure is still referenced from the CPU side and must not be reset.

This can happen when an interrupt vector is freed that still has a
handler installed, i.e. when the order of removing the handler and
freeing the vector is reversed.

Change-Id: Ib2dc5fa8f95a28b36e8f150dc8f16236ca4b2275
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3113
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Michael Lotz 2020-07-31 22:26:20 +02:00 committed by waddlesplash
parent d9ff5e5637
commit 4b6a48f4ae

View File

@ -708,7 +708,15 @@ free_io_interrupt_vectors(long count, long startVector)
startVector + i);
}
sVectors[startVector + i].assigned_cpu = NULL;
io_vector& vector = sVectors[startVector + i];
InterruptsSpinLocker vectorLocker(vector.vector_lock);
if (vector.assigned_cpu != NULL && vector.assigned_cpu->cpu != -1) {
panic("freeing io interrupt vector %ld that is still asigned to a "
"cpu", startVector + i);
continue;
}
vector.assigned_cpu = NULL;
sAllocatedIOInterruptVectors[startVector + i] = false;
}
}