Re: sound/pcm/* bugs (was: Re: page fault panic tracked down (selwakeuppri()) - really sound/pcm/*)

From: Don Lewis <truckman_at_FreeBSD.org>
Date: Tue, 13 Jan 2004 23:21:14 -0800 (PST)
On  8 Jan, Ryan Sommers wrote:
> While you guys are looking in snd_pcm here is a bug someone pointed out
> to on the lists in another form that I narrowed down. 
> 
> If you build snd_pcm and your another driver as modules and then only
> load snd_pcm.ko and not load your more specific driver you can panic the
> system every time by doing a "sysctl hw.snd.maxautovchans=(something
> other then current)". This has been sitting in my TODO list for awhile
> but I know nothing about sound driver code so you'd probably have more
> luck then I would. :) I'll attach the backtrace I grabbed from my latest
> CURRENT kernel. (I haven't checked if this is in a PR or not yet.)

The following patch prevents the panic for me. I don't know if EINVAL is
really the right error to return or if the code does the right thing if
the specific driver is loaded and unloaded ...

Index: sys/dev/sound/pcm/sound.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/sound/pcm/sound.c,v
retrieving revision 1.86
diff -u -r1.86 sound.c
--- sys/dev/sound/pcm/sound.c	8 Dec 2003 01:08:03 -0000	1.86
+++ sys/dev/sound/pcm/sound.c	14 Jan 2004 07:14:05 -0000
_at__at_ -334,7 +334,7 _at__at_
 	v = snd_maxautovchans;
 	error = sysctl_handle_int(oidp, &v, sizeof(v), req);
 	if (error == 0 && req->newptr != NULL) {
-		if (v < 0 || v >= SND_MAXVCHANS)
+		if (v < 0 || v >= SND_MAXVCHANS || pcm_devclass == NULL)
 			return EINVAL;
 		if (v != snd_maxautovchans) {
 			for (i = 0; i < devclass_get_maxunit(pcm_devclass); i++) {
Received on Tue Jan 13 2004 - 22:21:22 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:37 UTC