]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
sound: Fix NULL dereference in dsp_clone() and mixer_clone()
authorChristos Margiolis <christos@FreeBSD.org>
Sun, 28 Apr 2024 19:40:14 +0000 (21:40 +0200)
committerChristos Margiolis <christos@FreeBSD.org>
Sun, 28 Apr 2024 19:48:24 +0000 (21:48 +0200)
commit074d6fbebc160222cde6b726adcc7350881d7824
treef53b38563a1b5be9c59f8d50e9e910a55aa5f712
parent56ee5fc43c40479e2651b21862e299bcf73017ae
sound: Fix NULL dereference in dsp_clone() and mixer_clone()

If we only have a single soundcard attached and we detach it right
before entering [dsp|mixer]_clone(), there is a chance pcm_unregister()
will have returned already, meaning it will have set snd_unit to -1, and
thus devclass_get_softc() will return NULL here.

While here, 1) move the calls to dsp_destroy_dev() and mixer_uninit()
below the point where we unset SD_F_REGISTERED, and 2) follow what
mixer_clone() does and make sure we don't use a NULL d->dsp_dev in
dsp_clone().

Reported by: KASAN
Sponsored by: The FreeBSD Foundation
MFC after: 1 day
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D44924
sys/dev/sound/pcm/dsp.c
sys/dev/sound/pcm/mixer.c
sys/dev/sound/pcm/sound.c