From: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
To: Dean Gehnert <deang@tpi.com>, linux-kernel@vger.kernel.org
Cc: alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.com>,
stable@vger.kernel.org, Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH] ASoC: topology: Avoid card NULL deref in snd_soc_tplg_component_remove()
Date: Tue, 7 Jun 2022 09:40:15 +0200 [thread overview]
Message-ID: <238510b7-fc5f-4f1b-9e25-6e38b49c2535@linux.intel.com> (raw)
In-Reply-To: <20220603201425.2590-1-deang@tpi.com>
On 6/3/2022 10:14 PM, Dean Gehnert wrote:
> Don't deference card in comp->card->snd_card before checking for NULL card.
>
> During the unloading of ASoC kernel modules, there is a kernel oops in
> snd_soc_tplg_component_remove() that happens because comp->card is set to
> NULL in soc_cleanup_component().
>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: alsa-devel@alsa-project.org
> Cc: linux-kernel@vger.kernel.org
> Cc: stable@vger.kernel.org
> Fixes: 7e567b5ae063 ("ASoC: topology: Add missing rwsem around snd_ctl_remove() calls")
> Signed-off-by: Dean Gehnert <deang@tpi.com>
> ---
> sound/soc/soc-topology.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
> index 3f9d314fba16..cf0efe1147c2 100644
> --- a/sound/soc/soc-topology.c
> +++ b/sound/soc/soc-topology.c
> @@ -2613,15 +2613,18 @@ EXPORT_SYMBOL_GPL(snd_soc_tplg_component_load);
> /* remove dynamic controls from the component driver */
> int snd_soc_tplg_component_remove(struct snd_soc_component *comp)
> {
> - struct snd_card *card = comp->card->snd_card;
> + struct snd_card *card;
> struct snd_soc_dobj *dobj, *next_dobj;
> int pass;
>
> /* process the header types from end to start */
> for (pass = SOC_TPLG_PASS_END; pass >= SOC_TPLG_PASS_START; pass--) {
>
> + card = (comp->card) ? comp->card->snd_card : NULL;
> +
> /* remove mixer controls */
> - down_write(&card->controls_rwsem);
> + if (card)
> + down_write(&card->controls_rwsem);
> list_for_each_entry_safe(dobj, next_dobj, &comp->dobj_list,
> list) {
I'm pretty sure that quite a lot of operations in this
list_for_each_entry_safe() loop require existing card...
And trying to investigate more closely, there is no
soc_cleanup_component() mentioned in commit message, for quite a few
kernel versions - seems to have been removed during v5.5-rc1.
I would say to not merge this, unless problem can be reproduced with
latest kernel and even then would consider if it is a correct fix.
>
> @@ -2660,7 +2663,8 @@ int snd_soc_tplg_component_remove(struct snd_soc_component *comp)
> break;
> }
> }
> - up_write(&card->controls_rwsem);
> + if (card)
> + up_write(&card->controls_rwsem);
> }
>
> /* let caller know if FW can be freed when no objects are left */
next prev parent reply other threads:[~2022-06-07 7:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-03 20:14 Dean Gehnert
2022-06-07 7:40 ` Amadeusz Sławiński [this message]
2022-06-07 18:22 ` Dean Gehnert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=238510b7-fc5f-4f1b-9e25-6e38b49c2535@linux.intel.com \
--to=amadeuszx.slawinski@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=deang@tpi.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®