[patch] 2.1.84 sound oopses with SNDCTL_TMR_TEMPO

Frank van de Pol (F.K.W.van.de.Pol@inter.nl.net)
Tue, 3 Feb 1998 00:24:16 +0100 (MET)


Hi,

the recent kernels appear to have a bug within the sound timers. My code
crashes when I try to set the tempo directly after opening the /dev/music
device.

reason for the crash:
the sound_timer is not yet initialised, but it is already called from ioctl
SNDCTL_TMR_TEMPO dispatcher within sys_timer.c, which makes a call to
reprogram_timer(). This function tries to manipulate unitialised data and
BOOOM, we got an oops.

two possible ways to solve this:

- remove the reprogram_timer() from the said function (sys_timer.c, line 225)

or

- keep calling reprogram_timer(), and thus allow using this ioctl on a
running timer. Make the reprogram_timer() function 'forgiving' for being
called 'too early'. This is what next patch, against linux 2.1.84 does.

Regards,
Frank.

--- drivers/sound/sound_timer.c.2.1.84 Thu Jan 22 23:03:23 1998
+++ drivers/sound/sound_timer.c Mon Feb 2 22:23:15 1998
@@ -50,6 +50,10 @@
{
unsigned long usecs_per_tick;

+ /* bail out if this timer is not yet initialised */
+ if (tmr==NULL)
+ return;
+
usecs_per_tick = (60 * 1000000) / (curr_tempo * curr_timebase);

/*

========================---------------->
#define NAME "Frank van de Pol"
#define ADDRESS "mgr. Nelislaan 10"
#define CITY "4741 AB Hoeven"
#define COUNTRY "The Netherlands"
#define EMAIL "F.K.W.van.de.Pol@inter.NL.net -o)
/\\
Linux - Why use Windows, since there is a door? _\_v