Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Binbin Zhou" <zhoubinbin@loongson.cn>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 1/9] ASoC: loongson: Fix error handling in ACPI property parsing
Date: Fri, 26 Jun 2026 02:38:47 +0000	[thread overview]
Message-ID: <20260626023847.DFEAA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <08e44a54708eae053be148524346bb8dfcd55b03.1782439646.git.zhoubinbin@loongson.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The driver statically allocates global variables (`codec_name`, `loongson_dai_links`) and modifies them locklessly during the device probe phase without creating instance-specific copies. This leads to data races, state corruption on probe deferral, and a use-after-free vulnerability upon device unbind.
--

commit b0aab833787c20534a1a8d5a4fb96b7f089e37e4
Author: Binbin Zhou <zhoubinbin@loongson.cn>

ASoC: loongson: Fix error handling in ACPI property parsing

This commit fixes a missing error check for device_property_read_string()
in loongson_card_parse_acpi(). It propagates the error if the codec-dai-name
property is missing or invalid, preventing the use of an uninitialized
pointer.

Closes: https://sashiko.dev/#/patchset/cover.1780538113.git.zhoubinbin@loongson.cn?part=5

> diff --git a/sound/soc/loongson/loongson_card.c b/sound/soc/loongson/loongson_card.c
> --- a/sound/soc/loongson/loongson_card.c
> +++ b/sound/soc/loongson/loongson_card.c

[ ... ]

> @@ -108,7 +108,9 @@ static int loongson_card_parse_acpi(struct loongson_card_data *data)
>  		return -ENOENT;
>  	snprintf(codec_name, sizeof(codec_name), "i2c-%s", acpi_dev_name(adev));
>  
> -	device_property_read_string(card->dev, "codec-dai-name", &codec_dai_name);
> +	ret = device_property_read_string(card->dev, "codec-dai-name", &codec_dai_name);
> +	if (ret)
> +		return ret;
>  
>  	for (i = 0; i < card->num_links; i++) {
>  		loongson_dai_links[i].platforms->name = dev_name(phy_dev);

[Severity: High]
This is a pre-existing issue, but I noticed that loongson_dai_links appears
to be a statically allocated global array being modified locklessly here with
instance-specific pointers like dev_name(phy_dev).

If the device is unbound, could this leave a dangling pointer in the global
array?

Additionally, if multiple audio cards are instantiated, could they overwrite
each other's state in this shared array?

Similarly, in loongson_card_parse_of(), snd_soc_of_get_dlc() acquires a
reference to an of_node and stores it in this global array. If probe defers,
does the error path fail to clean up the globally stored refcount, causing
a memory leak?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1782439646.git.zhoubinbin@loongson.cn?part=1

  reply	other threads:[~2026-06-26  2:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26  2:27 [PATCH v3 0/9] ASoC: Add Loongson-2K0300 I2S controller and sound card support Binbin Zhou
2026-06-26  2:27 ` [PATCH v3 1/9] ASoC: loongson: Fix error handling in ACPI property parsing Binbin Zhou
2026-06-26  2:38   ` sashiko-bot [this message]
2026-06-26  2:27 ` [PATCH v3 2/9] ASoC: dt-bindings: loongson,ls2k1000-i2s: Document Loongson-2K0300 compatible Binbin Zhou
2026-06-26  2:27 ` [PATCH v3 3/9] ASoC: loongson: Add Loongson-2K0300 I2S controller support Binbin Zhou
2026-06-26  2:37   ` sashiko-bot
2026-06-26  2:27 ` [PATCH v3 4/9] ASoC: dt-bindings: loongson,ls-audio-card: Use common sound card Binbin Zhou
2026-06-26  2:37   ` sashiko-bot
2026-06-26  2:27 ` [PATCH v3 5/9] ASoC: dt-bindings: loongson,ls-audio-card: Add ctcisz forever pi compatible Binbin Zhou
2026-06-26  8:39   ` Krzysztof Kozlowski
2026-06-26  2:27 ` [PATCH v3 6/9] ASoC: loongson: Add Loongson-2K0300 CTCISZ Forever Pi sound card support Binbin Zhou
2026-06-26  2:38   ` sashiko-bot
2026-06-26  2:27 ` [PATCH v3 7/9] ASoC: dt-bindings: loongson,ls-audio-card: Add ATK-DL2K0300B compatible Binbin Zhou
2026-06-26  2:38   ` sashiko-bot
2026-06-26 10:01   ` Krzysztof Kozlowski
2026-06-26  2:27 ` [PATCH v3 8/9] ASoC: loongson: Add headphone jack detection and DAPM routing Binbin Zhou
2026-06-26  2:44   ` sashiko-bot
2026-06-26  2:27 ` [PATCH v3 9/9] ASoC: es8328: Add DAPM routes from MIC inputs to Mic Bias Binbin Zhou
2026-06-26  2:40   ` sashiko-bot

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=20260626023847.DFEAA1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=zhoubinbin@loongson.cn \
    /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