summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorariff <ariff@FreeBSD.org>2007-06-03 10:56:22 +0000
committerariff <ariff@FreeBSD.org>2007-06-03 10:56:22 +0000
commitd7e0dd317e778cefd5eb2237100d63c9515e7d74 (patch)
treeaf9d8d6a30e60d2859632a6bfde4ada021952cbe
parentf1272d430766538f2ffc5e528cfc1ab3e291f9c6 (diff)
downloadFreeBSD-src-d7e0dd317e778cefd5eb2237100d63c9515e7d74.zip
FreeBSD-src-d7e0dd317e778cefd5eb2237100d63c9515e7d74.tar.gz
Insert NULL pointer checking around devclass_get_maxunit(pcm_devclass, ..) .
Things can get ugly without it due to uninitialized class. RELENG_6 need a simmilar, but different treatment as well. err.. perhaps we should teach devclass_get_maxunit() to return -1 ? MFC after: 1 day
-rw-r--r--sys/dev/sound/pcm/dsp.c3
-rw-r--r--sys/dev/sound/pcm/mixer.c3
-rw-r--r--sys/dev/sound/pcm/sound.c12
3 files changed, 12 insertions, 6 deletions
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index 2d633b2..90453c1 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -1916,7 +1916,8 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *ai)
* Search for the requested audio device (channel). Start by
* iterating over pcm devices.
*/
- for (i = 0; i < devclass_get_maxunit(pcm_devclass); i++) {
+ for (i = 0; pcm_devclass != NULL &&
+ i < devclass_get_maxunit(pcm_devclass); i++) {
d = devclass_get_softc(pcm_devclass, i);
if (d == NULL)
continue;
diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c
index b0c2176..b7b5032 100644
--- a/sys/dev/sound/pcm/mixer.c
+++ b/sys/dev/sound/pcm/mixer.c
@@ -940,7 +940,8 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi)
* There's a 1:1 relationship between mixers and PCM devices, so
* begin by iterating over PCM devices and search for our mixer.
*/
- for (i = 0; i < devclass_get_maxunit(pcm_devclass); i++) {
+ for (i = 0; pcm_devclass != NULL &&
+ i < devclass_get_maxunit(pcm_devclass); i++) {
d = devclass_get_softc(pcm_devclass, i);
if (d == NULL)
continue;
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
index 3fe301d..dee3c99 100644
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -469,7 +469,8 @@ sysctl_hw_snd_maxautovchans(SYSCTL_HANDLER_ARGS)
if (v > SND_MAXVCHANS)
v = SND_MAXVCHANS;
snd_maxautovchans = v;
- for (i = 0; i < devclass_get_maxunit(pcm_devclass); i++) {
+ for (i = 0; pcm_devclass != NULL &&
+ i < devclass_get_maxunit(pcm_devclass); i++) {
d = devclass_get_softc(pcm_devclass, i);
if (d == NULL)
continue;
@@ -914,7 +915,8 @@ sysctl_hw_snd_clone_gc(SYSCTL_HANDLER_ARGS)
err = sysctl_handle_int(oidp, &val, sizeof(val), req);
if (err == 0 && req->newptr != NULL && val != 0) {
- for (i = 0; i < devclass_get_maxunit(pcm_devclass); i++) {
+ for (i = 0; pcm_devclass != NULL &&
+ i < devclass_get_maxunit(pcm_devclass); i++) {
d = devclass_get_softc(pcm_devclass, i);
if (d == NULL || d->clones == NULL)
continue;
@@ -1130,7 +1132,8 @@ pcm_unregister(device_t dev)
/*
* Reassign default unit to the next available dev.
*/
- for (i = 0; i < devclass_get_maxunit(pcm_devclass); i++) {
+ for (i = 0; pcm_devclass != NULL &&
+ i < devclass_get_maxunit(pcm_devclass); i++) {
if (device_get_unit(dev) == i ||
devclass_get_softc(pcm_devclass, i) == NULL)
continue;
@@ -1332,7 +1335,8 @@ sound_oss_sysinfo(oss_sysinfo *si)
if (pcm_devclass != NULL) {
j = 0;
- for (i = 0; i < devclass_get_maxunit(pcm_devclass); i++) {
+ for (i = 0; pcm_devclass != NULL &&
+ i < devclass_get_maxunit(pcm_devclass); i++) {
d = devclass_get_softc(pcm_devclass, i);
if (!d)
continue;
OpenPOWER on IntegriCloud