linux-sound.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Neuschäfer" <j.ne@posteo.net>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: "Mark Brown" <broonie@kernel.org>,
	"J. Neuschäfer" <j.ne@posteo.net>,
	linux-sound@vger.kernel.org
Subject: Re: [PATCH 1/2] ASoC: soc-core: care NULL dirver name on snd_soc_lookup_component_nolocked()
Date: Sat, 23 Aug 2025 22:55:27 +0000	[thread overview]
Message-ID: <aKpG3oy_uY3Z1Myl@probook> (raw)
In-Reply-To: <87ect8ysv8.wl-kuninori.morimoto.gx@renesas.com>

Hello,

On Tue, Aug 19, 2025 at 01:58:51AM +0000, Kuninori Morimoto wrote:
> soc-generic-dmaengine-pcm.c uses same dev for both CPU and Platform.
> In such case, CPU component driver might not have driver->name, then
> snd_soc_lookup_component_nolocked() will be NULL pointer access error.
> Care NULL driver name.
> 
> 	Call trace:
> 	 strcmp from snd_soc_lookup_component_nolocked+0x64/0xa4
> 	 snd_soc_lookup_component_nolocked from snd_soc_unregister_component_by_driver+0x2c/0x44
> 	 snd_soc_unregister_component_by_driver from snd_dmaengine_pcm_unregister+0x28/0x64
> 	 snd_dmaengine_pcm_unregister from devres_release_all+0x98/0xfc
> 	 devres_release_all from device_unbind_cleanup+0xc/0x60
> 	 device_unbind_cleanup from really_probe+0x220/0x2c8
> 	 really_probe from __driver_probe_device+0x88/0x1a0
> 	 __driver_probe_device from driver_probe_device+0x30/0x110
> 	driver_probe_device from __driver_attach+0x90/0x178
> 	__driver_attach from bus_for_each_dev+0x7c/0xcc
> 	bus_for_each_dev from bus_add_driver+0xcc/0x1ec
> 	bus_add_driver from driver_register+0x80/0x11c
> 	driver_register from do_one_initcall+0x58/0x23c
> 	do_one_initcall from kernel_init_freeable+0x198/0x1f4
> 	kernel_init_freeable from kernel_init+0x1c/0x12c
> 	kernel_init from ret_from_fork+0x14/0x28
> 
> Fixes: 144d6dfc7482 ("ASoC: soc-core: merge snd_soc_unregister_component() and snd_soc_unregister_component_by_driver()")
> Reported-by: J. Neuschäfer <j.ne@posteo.net>
> Closes: https://lore.kernel.org/r/aJb311bMDc9x-dpW@probook
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---

I can confirm that this patch (applied on top of v6.17-rc1) fixes the
NULL deref that I reported.

Tested-by: J. Neuschäfer <j.ne@posteo.net>

Thank you!


>  sound/soc/soc-core.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 37bc5867f81d4..c1cf205e05569 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -375,8 +375,9 @@ struct snd_soc_component
>  	for_each_component(component) {
>  		if ((dev == component->dev) &&
>  		    (!driver_name ||
> -		     (driver_name == component->driver->name) ||
> -		     (strcmp(component->driver->name, driver_name) == 0))) {
> +		     (component->driver->name &&
> +		      ((component->driver->name == driver_name) ||
> +		       (strcmp(component->driver->name, driver_name) == 0))))) {
>  			found_component = component;
>  			break;
>  		}
> -- 
> 2.43.0
> 

  parent reply	other threads:[~2025-08-23 22:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-19  1:58 [PATCH 0/2] ASoC: fixup snd_soc_lookup_component_nolocked() Kuninori Morimoto
2025-08-19  1:58 ` [PATCH 1/2] ASoC: soc-core: care NULL dirver name on snd_soc_lookup_component_nolocked() Kuninori Morimoto
2025-08-19  2:10   ` Kuninori Morimoto
2025-08-23 22:55   ` J. Neuschäfer [this message]
2025-08-19  1:59 ` [PATCH 2/2] ASoC: soc-core: tidyup snd_soc_lookup_component_nolocked() Kuninori Morimoto
2025-08-25 21:43 ` [PATCH 0/2] ASoC: fixup snd_soc_lookup_component_nolocked() Mark Brown

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=aKpG3oy_uY3Z1Myl@probook \
    --to=j.ne@posteo.net \
    --cc=broonie@kernel.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=linux-sound@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).