git: 74f11a40f8e4 - stable/13 - sound: test PCM_REGISTERED before PCM_DETACHING
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 30 Mar 2022 20:44:20 UTC
The branch stable/13 has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=74f11a40f8e4e1b3ae254edf499d467153242ce9
commit 74f11a40f8e4e1b3ae254edf499d467153242ce9
Author: Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-03-21 16:15:22 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-03-30 20:43:57 +0000
sound: test PCM_REGISTERED before PCM_DETACHING
PCM_REGISTERED(d) tests that d is not NULL, so perform that check first
as we may have cases where devclass_get_softc has a null entry.
PR: 262671
Reviewed by: hselasky
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34648
(cherry picked from commit da03ac41c9bca270b491fcf4bf219c4108688a05)
---
sys/dev/sound/pcm/mixer.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c
index 89e78b036e94..bbc57f737036 100644
--- a/sys/dev/sound/pcm/mixer.c
+++ b/sys/dev/sound/pcm/mixer.c
@@ -153,7 +153,7 @@ mixer_set_softpcmvol(struct snd_mixer *m, struct snddev_info *d,
struct pcm_channel *c;
int dropmtx, acquiremtx;
- if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
+ if (!PCM_REGISTERED(d) || PCM_DETACHING(d))
return (EINVAL);
if (mtx_owned(m->lock))
@@ -206,7 +206,7 @@ mixer_set_eq(struct snd_mixer *m, struct snddev_info *d,
else
return (EINVAL);
- if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
+ if (!PCM_REGISTERED(d) || PCM_DETACHING(d))
return (EINVAL);
if (mtx_owned(m->lock))
@@ -1083,7 +1083,7 @@ mixer_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
m = i_dev->si_drv1;
d = device_get_softc(m->dev);
- if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
+ if (!PCM_REGISTERED(d) || PCM_DETACHING(d))
return (EBADF);
/* XXX Need Giant magic entry ??? */
@@ -1239,7 +1239,7 @@ mixer_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode,
return (EBADF);
d = device_get_softc(((struct snd_mixer *)i_dev->si_drv1)->dev);
- if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
+ if (!PCM_REGISTERED(d) || PCM_DETACHING(d))
return (EBADF);
PCM_GIANT_ENTER(d);
@@ -1460,7 +1460,7 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi)
for (i = 0; pcm_devclass != NULL &&
i < devclass_get_maxunit(pcm_devclass); i++) {
d = devclass_get_softc(pcm_devclass, i);
- if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
+ if (!PCM_REGISTERED(d) || PCM_DETACHING(d))
continue;
/* XXX Need Giant magic entry */