Skip to contentSkip to conversation

ALSA: pcmtest: stop timer in the hw_free callback

PATCH Superseded Ivan Orlov 1 participant 1 message Dec 6, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ivan Orlov

author maintainer
#0 lore raw

PATCH 1/1 ALSA: pcmtest: stop timer in the hw_free callback

Stop timer in the 'hw_free' callback instead of the 'close' callback since we want the timer to be stopped before the DMA buffer is released. Otherwise, it could trigger a kernel panic in some circumstances, for instance when the DMA buffer is already released but the timer callback is still running.

---
 sound/drivers/pcmtest.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
sound/drivers/pcmtest.c +5 -2
index b59b78a09224..645caf1cc881 100644
@@ -396,8 +396,6 @@ static int snd_pcmtst_pcm_close(struct snd_pcm_substream *substream)
 {
 	struct pcmtst_buf_iter *v_iter = substream->runtime->private_data;
 
-	timer_shutdown_sync(&v_iter->timer_instance);
-	v_iter->substream = NULL;
 	playback_capture_test = !v_iter->is_buf_corrupted;
 	kfree(v_iter);
 	return 0;
@@ -499,6 +497,11 @@ static int snd_pcmtst_pcm_hw_params(struct snd_pcm_substream *substream,
 
 static int snd_pcmtst_pcm_hw_free(struct snd_pcm_substream *substream)
 {
+	struct pcmtst_buf_iter *v_iter = substream->runtime->private_data;
+
+	timer_shutdown_sync(&v_iter->timer_instance);
+	v_iter->substream = NULL;
+
 	return 0;
 }
 
Signature · 1 line
2.34.1