]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
mixer: Fix default_unit switching with mixers that have no devices
authorMark Johnston <markj@FreeBSD.org>
Mon, 16 Jan 2023 13:02:54 +0000 (08:02 -0500)
committerMark Johnston <markj@FreeBSD.org>
Mon, 16 Jan 2023 13:02:54 +0000 (08:02 -0500)
commit5c2b216a1cd8de3aabfa9e76ca8f38774acd591e
treea14d434bdbec09f8e7ab8bbeb9bb6357a21372e1
parent228c632ab3f6245df4a08d8692d49c8e12aacc27
mixer: Fix default_unit switching with mixers that have no devices

Apparently it's possible for a mixer to have no devices:

$ mixer -f /dev/mixer2
pcm2:mixer: <USB audio> at ? kld snd_uaudio (rec)
$

If this is the default sound device, an attempt to change the default
unit using mixer -d fails with a segfault because mod_dunit is called
with a NULL device pointer, which is dereferenced to get the parent
mixer.

ctl_dunit seems to be a dummy, i.e., we don't actually need it and can
simply pass the mixer to mod_dunit() directly.  This patch removes that
structure and associated indirection to fix the crash.

Reviewed by: christos, hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38060
usr.sbin/mixer/mixer.c