sound: Do not check for NULL if sbuf is allocated with SBUF_AUTOEXTEND

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D46846

(cherry picked from commit aaf84d0e96831cd886b8e1e4ae102b3ba703b90a)
This commit is contained in:
Christos Margiolis 2024-10-18 10:41:16 +02:00
parent 28dc9f54ef
commit 7a7ba76aa6
2 changed files with 2 additions and 9 deletions

View file

@ -951,12 +951,8 @@ midistat_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
return EBUSY;
}
midistat_isopen = 1;
if (sbuf_new(&midistat_sbuf, NULL, 4096, SBUF_AUTOEXTEND) == NULL) {
error = ENXIO;
goto out;
}
sbuf_new(&midistat_sbuf, NULL, 4096, SBUF_AUTOEXTEND);
error = (midistat_prepare(&midistat_sbuf) > 0) ? 0 : ENOMEM;
out:
if (error)
midistat_isopen = 0;
midistat_unlock();

View file

@ -150,10 +150,7 @@ sndstat_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
pf = malloc(sizeof(*pf), M_DEVBUF, M_WAITOK | M_ZERO);
if (sbuf_new(&pf->sbuf, NULL, 4096, SBUF_AUTOEXTEND) == NULL) {
free(pf, M_DEVBUF);
return (ENOMEM);
}
sbuf_new(&pf->sbuf, NULL, 4096, SBUF_AUTOEXTEND);
pf->fflags = flags;
TAILQ_INIT(&pf->userdev_list);