Date: Sun, 28 Apr 2024 19:49:00 GMT From: Christos Margiolis <christos@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: b18b990d8e7b - main - sound: Wrap dsp_clone() and mixer_clone() with bus_topo_lock() Message-ID: <202404281949.43SJn0bF063176@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=b18b990d8e7b15d25243d85ea22374dfdde8a18b commit b18b990d8e7b15d25243d85ea22374dfdde8a18b Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2024-04-28 19:40:29 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2024-04-28 19:48:24 +0000 sound: Wrap dsp_clone() and mixer_clone() with bus_topo_lock() Make sure that the softc isn't freed in between the checks. Sponsored by: The FreeBSD Foundation MFC after; 1 day Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44991 --- sys/dev/sound/pcm/dsp.c | 2 ++ sys/dev/sound/pcm/mixer.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index c5bb27530d2b..df1482d6a97a 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -2085,6 +2085,7 @@ dsp_clone(void *arg, struct ucred *cred, char *name, int namelen, } return; found: + bus_topo_lock(); d = devclass_get_softc(pcm_devclass, snd_unit); /* * If we only have a single soundcard attached and we detach it right @@ -2096,6 +2097,7 @@ found: *dev = d->dsp_dev; dev_ref(*dev); } + bus_topo_unlock(); } static void diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index 33a7eb26606d..2f4a6f4d6395 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -1377,12 +1377,14 @@ mixer_clone(void *arg, if (*dev != NULL) return; if (strcmp(name, "mixer") == 0) { + bus_topo_lock(); d = devclass_get_softc(pcm_devclass, snd_unit); /* See related comment in dsp_clone(). */ if (d != NULL && PCM_REGISTERED(d) && d->mixer_dev != NULL) { *dev = d->mixer_dev; dev_ref(*dev); } + bus_topo_unlock(); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404281949.43SJn0bF063176>