mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Kean Ren <rh_king@163.com>
Cc: Maciej Strozek <mstrozek@opensource.cirrus.com>,
	Bard Liao <yung-chuan.liao@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>, Vinod Koul <vkoul@kernel.org>,
	Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
	linux-sound@vger.kernel.org, patches@opensource.cirrus.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ASoC: SDCA: fix NULL pointer dereference in sdca_dev_unregister_functions
Date: Thu, 11 Jun 2026 10:07:50 +0100	[thread overview]
Message-ID: <aip65u81qQieT19U@opensource.cirrus.com> (raw)
In-Reply-To: <20260611023757.1553960-1-rh_king@163.com>

On Thu, Jun 11, 2026 at 10:37:57AM +0800, Kean Ren wrote:
> sdca_dev_unregister_functions() iterates over all SDCA function
> descriptors and calls sdca_dev_unregister() on each func_dev without
> checking for NULL. When a function registration has failed partway
> through, or the device cleanup races with probe deferral, func_dev
> entries may be NULL, leading to a kernel oops:
> 
>   BUG: kernel NULL pointer dereference, address: 0000000000000040
>   RIP: 0010:device_del+0x1e/0x3e0
>   Call Trace:
>    sdca_dev_unregister_functions+0x37/0x60 [snd_soc_sdca]
>    release_nodes+0x35/0xb0
>    devres_release_all+0x90/0x100
>    device_unbind_cleanup+0xe/0x80
>    device_release_driver_internal+0x1c1/0x200
>    bus_remove_device+0xc6/0x130
>    device_del+0x161/0x3e0
>    device_unregister+0x17/0x60
>    sdw_delete_slave+0xb6/0xd0 [soundwire_bus]
>    sdw_bus_master_delete+0x1e/0x50 [soundwire_bus]
>    ...
>    sof_probe_work+0x19/0x30 [snd_sof]
> 
> This was observed on a Lenovo ThinkPad X1 Carbon G14 (Panther Lake)
> with the SOF audio driver probe failing due to missing Panther Lake
> firmware, causing the subsequent cleanup of SoundWire devices to
> trigger the crash.
> 
> Fix this with three changes:
> 
> 1) Add a NULL guard in sdca_dev_unregister() so that callers do not
>    need to pre-validate the pointer (defense in depth).
> 
> 2) In sdca_dev_unregister_functions(), skip NULL func_dev entries
>    and clear func_dev to NULL after unregistration, making the
>    function idempotent and safe against double-invocation.
> 
> 3) In sdca_dev_register_functions(), roll back all previously
>    registered functions when a later one fails, so the function
>    array is never left in a partially-populated state.
> 
> Fixes: 4496d1c65bad ("ASoC: SDCA: add function devices")
> Signed-off-by: Kean Ren <rh_king@163.com>
> ---

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles

  reply	other threads:[~2026-06-11  9:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11  2:37 Kean Ren
2026-06-11  9:07 ` Charles Keepax [this message]
2026-06-11 14:55 ` 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=aip65u81qQieT19U@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=mstrozek@opensource.cirrus.com \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=rh_king@163.com \
    --cc=tiwai@suse.com \
    --cc=vkoul@kernel.org \
    --cc=yung-chuan.liao@linux.intel.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®