Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Srinivas Kandagatla" <srinivas.kandagatla@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [RFC PATCH 5/8] ASoC: SDCA: class_function: xlate sound-dai cell by entity index
Date: Wed, 22 Jul 2026 23:57:39 +0000	[thread overview]
Message-ID: <20260722235739.6E5C11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722234221.884765-6-srinivas.kandagatla@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing validation of `args->args_count` before accessing `args->args[0]` leads to reading uninitialized stack memory, causing arbitrary DAI matching or information leaks, and breaking the fallback for zero-cell sound-dai references.
--

--- Patch [5]: [RFC PATCH 5/8] ASoC: SDCA: class_function: xlate sound-dai cell by entity index ---
commit 1d17bfb5417d13a6da7e95f412ebc5f6ec81d329
Author: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>

ASoC: SDCA: class_function: xlate sound-dai cell by entity index
    
This commit registers a custom of_xlate_dai_name for SDCA functions. It maps 
a "sound-dai" phandle cell to a DAI by matching the cell value against the 
SDCA entity array index instead of relying on default positional mapping.

> diff --git a/sound/soc/sdca/sdca_class_function.c b/sound/soc/sdca/sdca_class_function.c
> index 905c96ed6172f..b0fbe243d732c 100644
> --- a/sound/soc/sdca/sdca_class_function.c
> +++ b/sound/soc/sdca/sdca_class_function.c
[ ... ]
> @@ -216,9 +216,44 @@ static int class_function_set_jack(struct snd_soc_component *component,
[ ... ]
> +static int class_function_of_xlate_dai_name(struct snd_soc_component *component,
> +					    const struct of_phandle_args *args,
> +					    const char **dai_name)
> +{
> +	struct class_function_drv *drv = snd_soc_component_get_drvdata(component);
> +	struct sdca_function_data *function = drv->function;
> +	int target = args->args[0];

[Severity: Medium]
Could this read uninitialized stack memory if args->args_count is 0?

When a devicetree defines #sound-dai-cells = <0> for the SDCA function node,
the core of_parse_phandle_with_args() successfully returns with args_count = 0.

Because the of_phandle_args structure is often allocated on the stack in 
callers like snd_soc_of_get_dlc(), the args->args array is left uninitialized.

Does this code need to verify args->args_count >= 1 before accessing
args->args[0] to prevent matching against random stack values?

If args_count is 0, should it return -ENOTSUPP to allow ALSA's default
0-cell handling to proceed instead of returning -EINVAL?

> +	int i;
> +
> +	for (i = 0; i < function->num_entities - 1; i++) {
[ ... ]
> +		if (i == target) {
> +			*dai_name = entity->label;
> +			return 0;
> +		}
> +	}
> +
> +	dev_err(component->dev, "xlate: no dataport entity at index %d (num_entities=%d)\n",
> +		target, function->num_entities);

[Severity: Medium]
If target is populated from an uninitialized args->args[0] due to a 0-cell
reference, does printing it here leak kernel stack memory to the log?

> +	return -EINVAL;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260722234221.884765-1-srinivas.kandagatla@oss.qualcomm.com?part=5

  reply	other threads:[~2026-07-22 23:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 23:42 [RFC PATCH 0/8] ASoC: SDCA: enable on DT platforms and add Qualcomm WCD9378 (Tambora) codec Srinivas Kandagatla
2026-07-22 23:42 ` [RFC PATCH 1/8] ASoC: SDCA: hw_params: program upstream Input Terminals for OT DAI Srinivas Kandagatla
2026-07-22 23:54   ` sashiko-bot
2026-07-22 23:42 ` [RFC PATCH 2/8] ASoC: SDCA: allow building without ACPI Srinivas Kandagatla
2026-07-22 23:59   ` sashiko-bot
2026-07-22 23:42 ` [RFC PATCH 3/8] ASoC: SDCA: expose class helpers with hw_ops for non-DisCo platforms Srinivas Kandagatla
2026-07-22 23:58   ` sashiko-bot
2026-07-22 23:42 ` [RFC PATCH 4/8] ASoC: SDCA: add PDE pre/post-pmu hooks to hw_ops Srinivas Kandagatla
2026-07-22 23:56   ` sashiko-bot
2026-07-22 23:42 ` [RFC PATCH 5/8] ASoC: SDCA: class_function: xlate sound-dai cell by entity index Srinivas Kandagatla
2026-07-22 23:57   ` sashiko-bot [this message]
2026-07-22 23:42 ` [RFC PATCH 6/8] ASoC: SDCA: register SDCA_FUNCTION_TYPE_SIMPLE_JACK in class function driver Srinivas Kandagatla
2026-07-22 23:56   ` sashiko-bot
2026-07-22 23:42 ` [RFC PATCH 7/8] dt-bindings: sound: qcom: add Tambora WCD9378 SDCA codec Srinivas Kandagatla
2026-07-22 23:51   ` sashiko-bot
2026-07-22 23:42 ` [RFC PATCH 8/8] ASoC: codecs: add Qualcomm Tambora (WCD9378) " Srinivas Kandagatla
2026-07-23  0:03   ` 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=20260722235739.6E5C11F000E9@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=srinivas.kandagatla@oss.qualcomm.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