From af54a3dd7c7581a3039838591aec14720e854684 Mon Sep 17 00:00:00 2001 From: Mark Farrugia Date: Tue, 20 Nov 2018 18:23:46 +1100 Subject: Fix missing 'close' PCM callback We need to have to close PCM callback set, otherwise we get a kernel crash when the PCM middle layer attempts to dereference a NULL pointer. Signed-off-by: Mark Farrugia --- pcm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pcm.c b/pcm.c index 411db40..0c6afa9 100644 --- a/pcm.c +++ b/pcm.c @@ -91,6 +91,22 @@ static int pcm_open(struct snd_pcm_substream *substream) return DO_AUDIOPATH_CB(audiopath, open, substream); } +/** + * pcm_close - Implements 'close' callback for PCM middle layer + * @substream: pointer to ALSA PCM substream + * + * This is called when a PCM substream is closed. + * + * Returns 0 on success or error code otherwise. + */ +static int pcm_close(struct snd_pcm_substream *substream) +{ + // Do additional Audio Path 'close' callback + return DO_AUDIOPATH_CB( + (struct snd_avirt_audiopath *)PRIVATE_DATA(substream)->audiopath, + close, substream); +} + /** * pcm_hw_params - Implements 'hw_params' callback for PCM middle layer * @substream: pointer to ALSA PCM substream @@ -154,6 +170,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) */ struct snd_pcm_ops pcm_ops_avirt = { .open = pcm_open, + .close = pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, -- cgit 1.2.3-korg