Subject: Detaching devices
To: None <>
From: Lennart Augustsson <>
List: tech-kern
Date: 06/27/1999 22:33:48
I'm trying to rewrite the USB detach code to do the right thing.  I have a question?

Imagine a device, e.g. a mouse, that has been opened for reading.  Now the device
is detached and its detach routine together with the general detach framework
will deallocate its softc and related data.
Well, what happens if the process that has it open is sleep()ing in read when this
happens?  First, nothing happens, but if this process then wakes up it will now try
and access data in a deallocated softc.  Not good.

Is the idea that the detach routine for a device should wake up any processes that
are still holding on to the device data?  And then make sure that they are finished
before finishing the detach.
If this is the case, will the general machinery guarantee that no new processes
enters the device driver while this is happening?

    -- Lennart