NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/46121: audiomp: locking protocol error



On Mon, Mar 26, 2012 at 06:07:02PM +1100, matthew green wrote:
> 
> this looks like it should do the trick.
...
>       mutex_enter(sc->sc_lock);
> !     can_playback = audio_can_playback(sc);
> !     can_capture = audio_can_capture(sc);
> !     mutex_exit(sc->sc_lock);
> ! 
> !     if (can_playback) {

Hmmm... that sort of code tends to look dubious [1].
While acquiring a mutex across a function call can protect the underlying
data from immediate corruption, it isn't necessarily obvious that
the checked condition can't change state after the mutex is released.

        David

[1] As does releaseing a mutex across a function call!

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index