git: 9693241188aa - main - sound: Call DSP_REGISTERED before PCM_DETACHING
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 24 Oct 2024 11:37:30 UTC
The branch main has been updated by christos:
URL: https://cgit.FreeBSD.org/src/commit/?id=9693241188aa6882166b091d9006f9d0affeda7e
commit 9693241188aa6882166b091d9006f9d0affeda7e
Author: Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-10-24 11:37:01 +0000
Commit: Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-10-24 11:37:01 +0000
sound: Call DSP_REGISTERED before PCM_DETACHING
DSP_REGISTERED first checks if the softc is not null, through
PCM_REGISTERED, which in turn calls PCM_ALIVE, whereas PCM_DETACHING
accesses the softc flags directly.
Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch, markj, emaste
Differential Revision: https://reviews.freebsd.org/D47195
---
sys/dev/sound/pcm/dsp.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index d4f7e3d6e63f..6573dfaabf2f 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -196,7 +196,7 @@ dsp_close(void *data)
d = priv->sc;
/* At this point pcm_unregister() will destroy all channels anyway. */
- if (PCM_DETACHING(d))
+ if (!DSP_REGISTERED(d) || PCM_DETACHING(d))
goto skip;
PCM_GIANT_ENTER(d);
@@ -301,7 +301,7 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
return (ENODEV);
d = i_dev->si_drv1;
- if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
+ if (!DSP_REGISTERED(d) || PCM_DETACHING(d))
return (EBADF);
priv = malloc(sizeof(*priv), M_DEVBUF, M_WAITOK | M_ZERO);
@@ -485,7 +485,7 @@ dsp_io_ops(struct dsp_cdevpriv *priv, struct uio *buf)
("%s(): io train wreck!", __func__));
d = priv->sc;
- if (PCM_DETACHING(d) || !DSP_REGISTERED(d))
+ if (!DSP_REGISTERED(d) || PCM_DETACHING(d))
return (EBADF);
PCM_GIANT_ENTER(d);
@@ -704,7 +704,7 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode,
return (err);
d = priv->sc;
- if (PCM_DETACHING(d) || !DSP_REGISTERED(d))
+ if (!DSP_REGISTERED(d) || PCM_DETACHING(d))
return (EBADF);
PCM_GIANT_ENTER(d);
@@ -1823,7 +1823,7 @@ dsp_poll(struct cdev *i_dev, int events, struct thread *td)
if ((err = devfs_get_cdevpriv((void **)&priv)) != 0)
return (err);
d = priv->sc;
- if (PCM_DETACHING(d) || !DSP_REGISTERED(d)) {
+ if (!DSP_REGISTERED(d) || PCM_DETACHING(d)) {
/* XXX many clients don't understand POLLNVAL */
return (events & (POLLHUP | POLLPRI | POLLIN |
POLLRDNORM | POLLOUT | POLLWRNORM));
@@ -1905,7 +1905,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset,
if ((err = devfs_get_cdevpriv((void **)&priv)) != 0)
return (err);
d = priv->sc;
- if (PCM_DETACHING(d) || !DSP_REGISTERED(d))
+ if (!DSP_REGISTERED(d) || PCM_DETACHING(d))
return (EINVAL);
PCM_GIANT_ENTER(d);