From 8be20fbe2a9733b75ac6f3cebb5e83ca16db412e Mon Sep 17 00:00:00 2001 From: Ariff Abdullah Date: Thu, 3 Nov 2005 08:19:04 +0000 Subject: [PATCH] Appropriate NULL pointer checking to avoid mysterious panic during device cloning. Approved by: netchild (mentor) --- sys/dev/sound/pcm/dsp.c | 2 +- sys/dev/sound/pcm/mixer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index 3cb09d7f504..5f94199e24a 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -1157,7 +1157,7 @@ dsp_clone(void *arg, struct ucred *cred, char *name, int namelen, panic("Unknown devtype %d", devtype); } - if ((pdev->si_drv1 == NULL) && (pdev->si_drv2 == NULL)) { + if ((pdev != NULL) && (pdev->si_drv1 == NULL) && (pdev->si_drv2 == NULL)) { *dev = pdev; dev_ref(*dev); return; diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index 6b8dac11dd4..b8f78d3cfab 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -515,7 +515,7 @@ mixer_clone(void *arg, struct ucred *cred, char *name, int namelen, return; if (strcmp(name, "mixer") == 0) { sd = devclass_get_softc(pcm_devclass, snd_unit); - if (sd != NULL) { + if (sd != NULL && sd->mixer_dev != NULL) { *dev = sd->mixer_dev; dev_ref(*dev); }