The SNDCTL_*INFO ioctls can report info about any device in the system,
not only the one they were issued on. Both the dsp and mixer dispatchers
unnecessarily busy the caller's device first. The caller's device is
kept alive anyway, until destroy_dev() drains the cdev threadcount.
Busying the wrong device also prevents the handlers from busying the one
they actually want to report info on, because this would recurse on the
sx whenever the two were the same, so they walk the channel lists under
PCM_LOCK instead.
Busy each device as it is being inspected, and give up the topology lock
once it is busied rather than holding it across the walks.
The vchan sysctls have the same problem. They look the device up under
the topology lock, drop it, and then busy the device, leaving a window
where the device can disappear. Busy it before dropping the lock there
too.
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation