]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.6.5/alsa-pcm-free-chmap-at-pcm-free-callback-too.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.6.5 / alsa-pcm-free-chmap-at-pcm-free-callback-too.patch
1 From a8ff48cb70835f48de5703052760312019afea55 Mon Sep 17 00:00:00 2001
2 From: Takashi Iwai <tiwai@suse.de>
3 Date: Fri, 8 Jul 2016 08:23:43 +0200
4 Subject: ALSA: pcm: Free chmap at PCM free callback, too
5
6 From: Takashi Iwai <tiwai@suse.de>
7
8 commit a8ff48cb70835f48de5703052760312019afea55 upstream.
9
10 The chmap ctls assigned to PCM streams are freed in the PCM disconnect
11 callback. However, since the disconnect callback isn't called when
12 the card gets freed before registering, the chmap ctls may still be
13 left assigned. They are eventually freed together with other ctls,
14 but it may cause an Oops at pcm_chmap_ctl_private_free(), as the
15 function refers to the assigned PCM stream, while the PCM objects have
16 been already freed beforehand.
17
18 The fix is to free the chmap ctls also at PCM free callback, not only
19 at PCM disconnect.
20
21 Reported-by: Laxminath Kasam <b_lkasam@codeaurora.org>
22 Signed-off-by: Takashi Iwai <tiwai@suse.de>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25 ---
26 sound/core/pcm.c | 14 ++++++++++----
27 1 file changed, 10 insertions(+), 4 deletions(-)
28
29 --- a/sound/core/pcm.c
30 +++ b/sound/core/pcm.c
31 @@ -849,6 +849,14 @@ int snd_pcm_new_internal(struct snd_card
32 }
33 EXPORT_SYMBOL(snd_pcm_new_internal);
34
35 +static void free_chmap(struct snd_pcm_str *pstr)
36 +{
37 + if (pstr->chmap_kctl) {
38 + snd_ctl_remove(pstr->pcm->card, pstr->chmap_kctl);
39 + pstr->chmap_kctl = NULL;
40 + }
41 +}
42 +
43 static void snd_pcm_free_stream(struct snd_pcm_str * pstr)
44 {
45 struct snd_pcm_substream *substream, *substream_next;
46 @@ -871,6 +879,7 @@ static void snd_pcm_free_stream(struct s
47 kfree(setup);
48 }
49 #endif
50 + free_chmap(pstr);
51 if (pstr->substream_count)
52 put_device(&pstr->dev);
53 }
54 @@ -1135,10 +1144,7 @@ static int snd_pcm_dev_disconnect(struct
55 for (cidx = 0; cidx < 2; cidx++) {
56 if (!pcm->internal)
57 snd_unregister_device(&pcm->streams[cidx].dev);
58 - if (pcm->streams[cidx].chmap_kctl) {
59 - snd_ctl_remove(pcm->card, pcm->streams[cidx].chmap_kctl);
60 - pcm->streams[cidx].chmap_kctl = NULL;
61 - }
62 + free_chmap(&pcm->streams[cidx]);
63 }
64 mutex_unlock(&pcm->open_mutex);
65 mutex_unlock(&register_mutex);