HomeFreeBSD

sound: Fix NULL dereference in dsp_clone() and mixer_clone()

Description

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

(cherry picked from commit 074d6fbebc160222cde6b726adcc7350881d7824)

Details

Provenance
christosAuthored on Sun, Apr 28, 7:40 PM
Reviewer
markj
Differential Revision
D44924: sound: Fix NULL dereference in dsp_clone() and mixer_clone()
Parents
rGac316062a747: sound: Remove obsolete chn_setvolume()
Branches
Unknown
Tags
Unknown