]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - pending-5.1/asoc-soc-core-fixup-references-at-soc_cleanup_card_resources.patch
Fix up backported ptrace patch
[thirdparty/kernel/stable-queue.git] / pending-5.1 / asoc-soc-core-fixup-references-at-soc_cleanup_card_resources.patch
1 From 29040d1ac569606fece70966179de272cfc0d4db Mon Sep 17 00:00:00 2001
2 From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
3 Date: Mon, 27 May 2019 16:51:34 +0900
4 Subject: ASoC: soc-core: fixup references at soc_cleanup_card_resources()
5
6 From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7
8 commit 29040d1ac569606fece70966179de272cfc0d4db upstream.
9
10 commit 53e947a0e1f7 ("ASoC: soc-core: merge card resources cleanup
11 method") merged cleanup method of snd_soc_instantiate_card() and
12 soc_cleanup_card_resources().
13
14 But, after this commit, if user uses unbind/bind to Component factor
15 drivers, Kernel might indicates refcount error at
16 soc_cleanup_card_resources().
17
18 The 1st reason is card->snd_card is still exist even though
19 snd_card_free() was called, but it is already cleaned.
20 We need to set NULL to it.
21
22 2nd is card->dapm and card create debugfs, but its dentry is still
23 exist even though it was removed. We need to set NULL to it.
24
25 Fixes: 53e947a0e1f7 ("ASoC: soc-core: merge card resources cleanup method")
26 Cc: stable@vger.kernel.org # for v5.1
27 Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
28 Signed-off-by: Mark Brown <broonie@kernel.org>
29 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30
31 ---
32 sound/soc/soc-core.c | 7 ++++++-
33 sound/soc/soc-dapm.c | 3 +++
34 2 files changed, 9 insertions(+), 1 deletion(-)
35
36 --- a/sound/soc/soc-core.c
37 +++ b/sound/soc/soc-core.c
38 @@ -228,7 +228,10 @@ static void soc_init_card_debugfs(struct
39
40 static void soc_cleanup_card_debugfs(struct snd_soc_card *card)
41 {
42 + if (!card->debugfs_card_root)
43 + return;
44 debugfs_remove_recursive(card->debugfs_card_root);
45 + card->debugfs_card_root = NULL;
46 }
47
48 static void snd_soc_debugfs_init(void)
49 @@ -2034,8 +2037,10 @@ static void soc_check_tplg_fes(struct sn
50 static int soc_cleanup_card_resources(struct snd_soc_card *card)
51 {
52 /* free the ALSA card at first; this syncs with pending operations */
53 - if (card->snd_card)
54 + if (card->snd_card) {
55 snd_card_free(card->snd_card);
56 + card->snd_card = NULL;
57 + }
58
59 /* remove and free each DAI */
60 soc_remove_dai_links(card);
61 --- a/sound/soc/soc-dapm.c
62 +++ b/sound/soc/soc-dapm.c
63 @@ -2192,7 +2192,10 @@ static void dapm_debugfs_add_widget(stru
64
65 static void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm)
66 {
67 + if (!dapm->debugfs_dapm)
68 + return;
69 debugfs_remove_recursive(dapm->debugfs_dapm);
70 + dapm->debugfs_dapm = NULL;
71 }
72
73 #else