Re: Kernel crash in snd-aloop (2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

So after much experimentation and thinking, I think I can come up with the
following scenario why the kernel crashes:

When the aloop soundcard is closed by jackd, all data structures are freed.
This is OK, but the code forgets to check if any timers are still running.
Most of the time this goes well and nothing bad happens. But sometimes the
dpcm->timer.function fires after all data is cleaned up/freed. And that is
of course not very desirable.

I've attached a patch to the alsa-driver-hg20080516 version of
drivers/aloop-kernel.c This patch does a del_timer() in three places, I
would love to hear feedback from you guys on the list if some del_timers can
be eliminated? It seems a bit paranoia but it works perfectly in my test
setup.

So what do you guys think? I've never submitted patches before so I'm not
sure if this is the correct procedure. Please correct me if necessary...

Kind regards,
Benjamin van den Hout
--- alsa-driver-hg20080516/drivers/aloop-kernel.c	2008-05-22 13:37:09.000000000 +0200
+++ alsa-driver-hg20080516.patch/drivers/aloop-kernel.c	2008-05-22 14:49:12.000000000 +0200
@@ -232,6 +232,8 @@
 static void snd_card_loopback_runtime_free(struct snd_pcm_runtime *runtime)
 {
 	snd_card_loopback_pcm_t *dpcm = runtime->private_data;
+	snd_assert(dpcm != NULL, return);
+	del_timer(&dpcm->timer);
 	kfree(dpcm);
 }
 
@@ -265,6 +267,9 @@
 	snd_card_loopback_pcm_t *dpcm = runtime->private_data;
 	snd_card_loopback_cable_t *cable = dpcm->cable;
 
+	snd_assert(dpcm != NULL, return -EINVAL);
+	del_timer(&dpcm->timer);
+
 	snd_pcm_set_runtime_buffer(substream, NULL);
 
 	if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) {
@@ -349,6 +354,10 @@
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	snd_card_loopback_pcm_t *dpcm = runtime->private_data;
+
+	snd_assert(dpcm != NULL, return -EINVAL);
+	del_timer(&dpcm->timer);
+
 	if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) {
 		dpcm->cable->playback_valid = 0;
 		dpcm->cable->playback_running = 0;
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux