kldunload and device detach panics

From: Duncan Barclay <dmlb_at_dmlb.org>
Date: Mon, 26 May 2003 20:22:09 +0100
Hi

Whilst starting work on porting the Linux Broadcom 440x 10/100 driver I've
come across a bit of
a problem with kldunload and its interaction with device xxx_detach.

I'm cribbing code from if_bge.c and if_rl.c (picked at random). if_rl.c uses
a mutex for locking the softc. If the rl_detach routine is called twice (for
example failing attach and then kldunload) the mutex gets destroyed twice -
leading to a panic with witness.

Is there a safe sequence of mutex checking etc. to avoid killing the machine
in this way? At present I'm assuming that if the mutex is not initialised
then _detach doesn't need to clean as nothing could have been set up, or it
has already been cleaned.

Duncan
Received on Mon May 26 2003 - 10:22:03 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:09 UTC