modular sound problem in 2.1.122

Mikael Pettersson (mikpe@csd.uu.se)
Sat, 19 Sep 1998 18:06:29 +0200 (MET DST)


Linux 2.1.122 applied the following patch to drivers/sound/sb_common.c:

@@ -951,10 +954,13 @@
if (!(devc->caps & SB_NO_AUDIO && devc->caps & SB_NO_MIDI) && devc->irq > 0)
{
free_irq(devc->irq, devc);
- sound_unload_mixerdev(devc->my_mixerdev);
+ if (devc->my_mixerdev)
+ sound_unload_mixerdev(devc->my_mixerdev);
/* We don't have to do this bit any more the UART401 is its own
master -- Krzysztof Halasa */
- /* sound_unload_mididev(devc->my_mididev); */
+ /* But we have to do it, if UART401 is not detected */
+ if (!sbmpu && devc->my_mididev)
+ sound_unload_mididev(devc->my_mididev);
sound_unload_audiodev(devc->my_dev);
}
kfree(devc);

This patch has two problems:
1. The sound_unload_{mixer,midi}dev() functions already perform the
necessary argument range checks (see dev_table.c).
2. The checks as written here are WRONG: the sentinel for absent
devices is -1, not zero. (Yet another reason not to repeat
the checks: you may not get it right...)

If one builds the modular sound drivers, the effect of this is to
prevent unloading the mixer or midi devices when the sb module
is unloaded. This leaves the soundcore module with a non-zero
reference count, so _it_ cannot be unloaded and future accesses
to the sound devices fail.

A tested fix for linux 2.1.122 follows below.

/Mikael

--- linux-2.1.122/drivers/sound/sb_common.c.~1~ Sat Sep 19 15:10:10 1998
+++ linux-2.1.122/drivers/sound/sb_common.c Sat Sep 19 16:35:15 1998
@@ -954,12 +954,11 @@
if (!(devc->caps & SB_NO_AUDIO && devc->caps & SB_NO_MIDI) && devc->irq > 0)
{
free_irq(devc->irq, devc);
- if (devc->my_mixerdev)
- sound_unload_mixerdev(devc->my_mixerdev);
+ sound_unload_mixerdev(devc->my_mixerdev);
/* We don't have to do this bit any more the UART401 is its own
master -- Krzysztof Halasa */
/* But we have to do it, if UART401 is not detected */
- if (!sbmpu && devc->my_mididev)
+ if (!sbmpu)
sound_unload_mididev(devc->my_mididev);
sound_unload_audiodev(devc->my_dev);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/