From: sashiko-bot@kernel.org
To: "Qianghua Wang" <qianghua.wang@senarytech.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v2 2/3] ASoC: sdw_utils: add SN622x codec_info and DAPM hooks
Date: Tue, 01 Dec 2026 03:08:36 +0000 [thread overview]
Message-ID: <sashiko-outbox-242403@kernel.org> (raw)
In-Reply-To: <20261201025636.60506-3-qianghua.wang@senarytech.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] ASoC: sdw_utils: amp_exit refcount underflow and skipped
rtd_init_done reset
- [Medium] ASoC: sdw_utils: hardcoded sn624x fallback in
asoc_sdw_senary_dmic_rtd_init()
--
commit d30e9f295b29e6f872bab08cdf9991bdd8b978e4
Author: Qianghua Wang <qianghua.wang@senarytech.com>
ASoC: sdw_utils: add SN622x codec_info and DAPM hooks
This commit registers SoundWire codec_info_list entries and speaker DAPM
routes for Senary SN6220 and SN6224, and shares the Senary DMIC widgets,
controls, and routing helper across SN622x and SN624x.
> diff --git a/sound/soc/sdw_utils/soc_sdw_senary_dmic.c b/sound/soc/sdw_utils/soc_sdw_senary_dmic.c
> index 725f4658ec9c7..ab351a5c1ec9e 100644
> --- a/sound/soc/sdw_utils/soc_sdw_senary_dmic.c
> +++ b/sound/soc/sdw_utils/soc_sdw_senary_dmic.c
> @@ -24,17 +19,23 @@ int asoc_sdw_senary_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_so
> struct snd_soc_card *card = rtd->card;
> struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
> struct snd_soc_component *component;
> + struct snd_soc_dapm_route route;
> + char *codec_dmic;
> char *mic_name;
> int ret;
>
> component = dai->component;
>
> if (component->name_prefix) {
> - ret = snd_soc_dapm_add_routes(dapm, senary_dmic_map,
> - ARRAY_SIZE(senary_dmic_map));
> + codec_dmic = devm_kasprintf(card->dev, GFP_KERNEL, "%s DMIC",
> + component->name_prefix);
> + if (!codec_dmic)
> + return -ENOMEM;
> + route = (struct snd_soc_dapm_route){ codec_dmic, NULL, "Dmic" };
> + ret = snd_soc_dapm_add_routes(dapm, &route, 1);
> mic_name = devm_kstrdup(card->dev, component->name_prefix, GFP_KERNEL);
> } else {
> - dev_warn(card->dev, "sn624x dmic: component %s has no name_prefix\n",
> + dev_warn(card->dev, "senary dmic: component %s has no name_prefix\n",
> component->name);
> ret = snd_soc_dapm_add_routes(dapm, senary_dmic_map_bare,
> ARRAY_SIZE(senary_dmic_map_bare));
[Severity: Medium]
Should the fallback branch below this derive mic_name from dai->name
instead of hardcoding "sn624x"? When component->name_prefix is NULL on an
SN6220 or SN6224 system, this still sets mic_name to "sn624x" and appends
"mic:sn624x-dmic" to card->components, breaking UCM microphone matching.
> diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c
> index b6acf7616d147..b048e9e115abb 100644
> --- a/sound/soc/sdw_utils/soc_sdw_utils.c
> +++ b/sound/soc/sdw_utils/soc_sdw_utils.c
[ ... ]
> @@ -1690,16 +1690,183 @@ struct asoc_sdw_codec_info codec_info_list[] = {
[ ... ]
> + /* SN6220, part_id 0x184c */
> + {
> + .vendor_id = 0x0496,
> + .part_id = 0x184c,
> + .name_prefix = "sn622x",
> + .ignore_internal_dmic = true,
> + .dais = {
> + {
> + .direction = {true, false},
> + .dai_name = "sn622x-sdca-aif",
> + .component_name = "sn622x",
> + .dai_type = SOC_SDW_DAI_TYPE_AMP,
> + .dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
> + .init = asoc_sdw_senary_amp_init,
> + .exit = asoc_sdw_senary_amp_exit,
> + .rtd_init = asoc_sdw_senary_sdca_spk_rtd_init,
> + .controls = generic_spk_controls,
> + .num_controls = ARRAY_SIZE(generic_spk_controls),
> + .widgets = generic_spk_widgets,
> + .num_widgets = ARRAY_SIZE(generic_spk_widgets),
> + .quirk = SOC_SDW_CODEC_SPKR,
> + .quirk_exclude = true,
> + },
> + {
> + .direction = {false, true},
> + .dai_name = "sn622x-sdca-aif2",
> + .dai_type = SOC_SDW_DAI_TYPE_MIC,
> + .dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID},
> + .rtd_init = asoc_sdw_senary_dmic_rtd_init,
> + .widgets = senary_dmic_widgets,
> + .num_widgets = ARRAY_SIZE(senary_dmic_widgets),
> + .controls = senary_dmic_controls,
> + .num_controls = ARRAY_SIZE(senary_dmic_controls),
> + .quirk = SOC_SDW_CODEC_MIC,
> + .quirk_exclude = true,
> + },
> + },
> + .dai_num = 2,
> + },
[Severity: High]
Does wiring .exit = asoc_sdw_senary_amp_exit on dais[0] across all four
SN622x codec_info_list entries underflow ctx->amp_dev1 and ctx->amp_dev2
and skip resetting dais[1].rtd_init_done on card teardown?
asoc_sdw_mc_dailink_exit_loop() matches used DAIs by dai_name:
sound/soc/sdw_utils/soc_sdw_utils.c:asoc_sdw_mc_dailink_exit_loop() {
...
for (i = 0; i < ctx->codec_info_list_count; i++) {
for (j = 0; j < codec_info_list[i].dai_num; j++) {
codec_info_list[i].dais[j].rtd_init_done = false;
/* Check each dai in codec_info_lis to see if it is used in the link */
if (!codec_info_list[i].dais[j].exit)
continue;
dai_link = asoc_sdw_mc_find_codec_dai_used(card,
codec_info_list[i].dais[j].dai_name);
if (dai_link) {
/* Do the .exit function if the codec dai is used in the link */
ret = codec_info_list[i].dais[j].exit(card, dai_link);
if (ret)
dev_warn(card->dev,
"codec exit failed %d\n",
ret);
break;
}
}
}
}
Because all four SN622x entries share dais[0].dai_name = "sn622x-sdca-aif",
teardown matches dais[0] on every entry and calls asoc_sdw_senary_amp_exit()
four times. Unlike asoc_sdw_rt_amp_exit(), asoc_sdw_senary_amp_exit() does
not clear ctx->amp_dev1 or ctx->amp_dev2 to NULL after calling
device_remove_software_node() and put_device(), so on systems with two
aggregated amplifiers it drops each device reference four times, causing a
refcount underflow and use-after-free.
In addition, hitting break at j = 0 on every SN622x entry skips j = 1
("sn622x-sdca-aif2"), leaving dais[1].rtd_init_done set to true so a
subsequent card probe skips DMIC widget, control, and route initialization.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201025636.60506-1-qianghua.wang@senarytech.com?part=2
next prev parent reply other threads:[~2026-12-01 3:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 2:56 [PATCH v2 0/3] ASoC: add Senary SN622x SDCA SoundWire support Qianghua Wang
2026-12-01 2:56 ` [PATCH v2 1/3] ASoC: codecs: add SN622x SDCA SoundWire codec support Qianghua Wang
2026-12-01 3:23 ` sashiko-bot
2026-12-01 17:26 ` Pierre-Louis Bossart
2026-12-02 2:07 ` repl: " qianghua.wang
2026-12-01 2:56 ` [PATCH v2 2/3] ASoC: sdw_utils: add SN622x codec_info and DAPM hooks Qianghua Wang
2026-12-01 3:08 ` sashiko-bot [this message]
2026-12-01 2:56 ` [PATCH v2 3/3] ASoC: Intel: soc-acpi: add SN622x PTL/NVL SoundWire machines Qianghua Wang
2026-12-01 3:06 ` 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=sashiko-outbox-242403@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=qianghua.wang@senarytech.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.