From: sashiko-bot@kernel.org
To: "H. Nikolaus Schaller" <hns@goldelico.com>
Cc: robh@kernel.org, dri-devel@lists.freedesktop.org,
mfd@lists.linux.dev, conor+dt@kernel.org,
devicetree@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH 10/16] ASoC: omap3pandora: Rewrite sound card driver as a platform driver with DT
Date: Sat, 11 Jul 2026 06:15:18 +0000 [thread overview]
Message-ID: <20260711061519.0D85B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <9274200e1ef2bc0e8df267a4b093b99f563c9c90.1783749722.git.hns@goldelico.com>
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
- [Critical] Device Tree ABI breakage due to removal of fallback machine-compatible matching and strict requirement for new DT nodes/properties.
- [High] Double-decrement of sample rate user count when `grab_sample_rate()` fails.
- [High] `relax_sample_rate()` incorrectly excludes hardware's minimum and maximum sample rates and permanently erases constraints applied by other components.
- [High] Static global `snd_soc_card` structure reuse causes list corruption on multiple probes and dangling pointer Use-After-Free.
- [High] Calling `mutex_destroy()` synchronously in `.remove` while using devm-based sound card registration creates a Use-After-Free vulnerability.
- [Medium] Missing `mutex_destroy()` on early probe error paths.
- [Low] Unused variable `codec_dai` in `omap3pandora_common_hw_params`.
--
--- Patch [10]: [PATCH 10/16] ASoC: omap3pandora: Rewrite sound card driver as a platform driver with DT ---
commit 8781d4ef4d1eb0b2da4ee910133603e631f2f4a9
Author: Stefan Leichter <sle85276@gmx.de>
ASoC: omap3pandora: Rewrite sound card driver as a platform driver with DT
This change converts the omap3pandora sound card driver to a standard
platform driver matched via Device Tree. It also moves code into the
PCM1773 codec driver and splits capture/playback operations.
> diff --git a/sound/soc/ti/omap3pandora.c b/sound/soc/ti/omap3pandora.c
> index 6c9c184cd9d6f..d3509473f5df0 100644
> --- a/sound/soc/ti/omap3pandora.c
> +++ b/sound/soc/ti/omap3pandora.c
[ ... ]
> -static int omap3pandora_hw_params(struct snd_pcm_substream *substream,
> - struct snd_pcm_hw_params *params)
> +static int omap3pandora_common_hw_params(struct snd_pcm_substream *substream,
> + struct snd_pcm_hw_params *params)
> {
> struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
> struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
[Severity: Low]
Is codec_dai used anywhere in this function now? It looks like the usage
was moved to omap3pandora_capture_hw_params(), leaving this variable unused
and potentially causing build warnings.
[ ... ]
> +static inline void relax_sample_rate(struct snd_pcm_substream *substream)
> +{
> + const struct snd_interval default_sample_rate_range = {
> + .min = substream->runtime->hw.rate_min,
> + .max = substream->runtime->hw.rate_max,
> + .openmin = 1,
> + .openmax = 1,
> + };
> +
> + *constrs_interval(&substream->runtime->hw_constraints,
> + SNDRV_PCM_HW_PARAM_RATE) =
> + default_sample_rate_range;
> +}
[Severity: High]
Does setting openmin and openmax to 1 permanently exclude the hardware's
exact minimum and maximum supported rates? It seems this would block rates
like exactly 8000 Hz or 96000 Hz from being selected, as these flags make
the interval mathematically open.
Also, does overwriting the hw_constraints interval directly via
pointer assignment permanently erase other constraints that might have
been applied by the CPU DAI or Codec DAI?
[ ... ]
> +static int omap3pandora_playback_hw_params(struct snd_pcm_substream *substream,
> + struct snd_pcm_hw_params *params)
> +{
[ ... ]
> + if (!ctx->playback_stream) {
> + ctx->playback_stream = substream;
> + ret = grab_sample_rate(ctx, substream, params);
> + if (ret)
> + return ret;
> + }
[Severity: High]
Could this lead to a double-decrement of the sample rate user count?
If grab_sample_rate() fails due to a sample rate mismatch, it will call
release_sample_rate() and decrement the count. However, since
ctx->playback_stream is assigned before grab_sample_rate(), the ALSA core's
subsequent call to omap3pandora_playback_hw_free() will see
ctx->playback_stream as non-NULL and call release_sample_rate() a second
time.
The same pattern appears in omap3pandora_capture_hw_params(). Should the
stream pointer assignment happen after grab_sample_rate() succeeds, or
should it be cleared in the error path?
[ ... ]
> /* SoC card */
> static struct snd_soc_card snd_soc_card_omap3pandora = {
> - .name = "omap3pandora",
> - .owner = THIS_MODULE,
> - .dai_link = omap3pandora_dai,
> - .num_links = ARRAY_SIZE(omap3pandora_dai),
> -
> - .dapm_widgets = omap3pandora_dapm_widgets,
> - .num_dapm_widgets = ARRAY_SIZE(omap3pandora_dapm_widgets),
> - .dapm_routes = omap3pandora_map,
> - .num_dapm_routes = ARRAY_SIZE(omap3pandora_map),
> + .name = "omap3pandora",
> + .owner = THIS_MODULE,
> + .dai_link = omap3pandora_dai,
> + .num_links = ARRAY_SIZE(omap3pandora_dai),
> + .dapm_widgets = omap3pandora_local_widgets,
> + .num_dapm_widgets = ARRAY_SIZE(omap3pandora_local_widgets),
> };
>
> -static struct platform_device *omap3pandora_snd_device;
> -
> -static int __init omap3pandora_soc_init(void)
> +static int omap3pandora_probe(struct platform_device *pdev)
> {
> int ret;
> + struct device *dev = &pdev->dev;
> + struct snd_soc_card *card = &snd_soc_card_omap3pandora;
> + struct omap3pandora_sound *ctx;
>
> + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> + if (!ctx)
> return -ENOMEM;
>
> + mutex_init(&ctx->sample_rate_lock);
>
> + ctx->amp_gpio = devm_gpiod_get(dev, "amp", GPIOD_OUT_LOW);
> + if (IS_ERR(ctx->amp_gpio)) {
> + dev_err(dev, "cannot find amplifier gpio\n");
> + return PTR_ERR(ctx->amp_gpio);
> }
>
> + ctx->amp_regulator = devm_regulator_get(dev, "amp");
> + if (IS_ERR(ctx->amp_regulator)) {
> + ret = PTR_ERR(ctx->amp_regulator);
> + dev_err(dev, "Failed to request regulator for amplifier power: %d\n", ret);
> + return ret;
> }
[Severity: Medium]
Do these early error returns leak the lockdep tracking for the mutex?
Since mutex_init() is called before these checks, shouldn't they use goto
err_mutex instead of returning directly?
[ ... ]
> + if (dev->of_node) {
> + ret = snd_soc_of_parse_card_name(card, "label");
> + if (ret)
> + card->name = "omap3pandora";
> +
> + ret = snd_soc_of_parse_audio_simple_widgets(card, "widgets");
[Severity: High]
Does modifying the static global snd_soc_card_omap3pandora structure
in probe() create issues if the driver is unbound and rebound?
Functions like snd_soc_of_parse_audio_simple_widgets() allocate memory
with devm_kcalloc() and assign it to the card structure. If unbound, devres
frees the memory, leaving dangling pointers in the static structure.
Furthermore, probing multiple times could corrupt the global linked list
by calling list_add() on the same card->list node twice.
> + if (ret) {
> + dev_err(dev, "Failed to parse DAPM widgets: %d\n", ret);
> + goto err_mutex;
> + }
> +
> + ret = snd_soc_of_parse_audio_routing(card, "routing");
> + if (ret) {
> + dev_err(dev, "Failed to parse audio routing: %d\n", ret);
> + goto err_mutex;
> + }
> }
[Severity: Critical]
Does this strict property check break compatibility with older Device Trees?
The previous driver automatically instantiated the sound card based on the
root machine compatible string. By unconditionally requiring the new widgets
and routing properties and failing if they are absent, will users booting a
new kernel with an older DT lose audio functionality completely?
> + snd_soc_card_set_drvdata(card, ctx);
> +
> + ret = devm_snd_soc_register_card(dev, card);
> + if (ret) {
> + dev_err(dev, "Failed to register sound card: %d\n", ret);
> + goto err_mutex;
> }
>
> return 0;
>
> +err_mutex:
> + mutex_destroy(&ctx->sample_rate_lock);
> return ret;
> }
>
> -module_init(omap3pandora_soc_init);
>
> -static void __exit omap3pandora_soc_exit(void)
> +static void omap3pandora_remove(struct platform_device *pdev)
> {
> - regulator_put(omap3pandora_dac_reg);
> - platform_device_unregister(omap3pandora_snd_device);
> + struct snd_soc_card *card = platform_get_drvdata(pdev);
> + struct omap3pandora_sound *ctx = snd_soc_card_get_drvdata(card);
> +
> + mutex_destroy(&ctx->sample_rate_lock);
> }
[Severity: High]
Can destroying the mutex here lead to a use-after-free or lockdep panic?
The sound card is registered using devm_snd_soc_register_card(), which
defers unregistration to the devres cleanup phase. This runs after the
omap3pandora_remove() function returns.
If we call mutex_destroy() synchronously in .remove, does this leave a
window where the sound card is still fully active and exposed to userspace,
but its internal lock has been destroyed?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1783749722.git.hns@goldelico.com?part=10
next prev parent reply other threads:[~2026-07-11 6:15 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 6:01 [PATCH 00/16] ARM: omap3: pandora: Modernize audio and backlight to Device Tree to finally remove pdata-quirks H. Nikolaus Schaller
2026-07-11 6:01 ` [PATCH 01/16] dt-bindings: twl-regulator: Add bindings for exposing ti, twl4030-regen H. Nikolaus Schaller
2026-07-11 6:10 ` sashiko-bot
2026-07-11 6:01 ` [PATCH 02/16] regulator: twl: Expose the TWL4030's REGEN signal as a regulator H. Nikolaus Schaller
2026-07-11 6:16 ` sashiko-bot
2026-07-11 6:01 ` [PATCH 03/16] arm: dts: twl4030: add twl4030-regen child H. Nikolaus Schaller
2026-07-11 6:18 ` sashiko-bot
2026-07-11 6:01 ` [PATCH 04/16] arm: dts: omap3pandora: Populate DT data for the TWL4030's REGEN regulator H. Nikolaus Schaller
2026-07-11 6:19 ` sashiko-bot
2026-07-11 6:01 ` [PATCH 05/16] arm: dts: omap3pandora: Don't use DMA channels for unused SPI masters H. Nikolaus Schaller
2026-07-11 6:06 ` sashiko-bot
2026-07-11 6:01 ` [PATCH 06/16] ASoC: twl4030-codec: Allow setting APLL rate through the .set_sysclk() interface H. Nikolaus Schaller
2026-07-11 6:12 ` sashiko-bot
2026-07-11 6:01 ` [PATCH 07/16] ASoC: dt-bindings: add TI PCM1773 H. Nikolaus Schaller
2026-07-11 6:08 ` sashiko-bot
2026-07-11 7:39 ` Rob Herring (Arm)
2026-07-11 6:01 ` [PATCH 08/16] ASoC: pcm1773-codec: write a driver for the PCM1773 chip from TI H. Nikolaus Schaller
2026-07-11 6:14 ` sashiko-bot
2026-07-11 6:01 ` [PATCH 09/16] ASoC: dt-bindings: add OpenPandora Sound Card H. Nikolaus Schaller
2026-07-11 6:10 ` sashiko-bot
2026-07-11 7:39 ` Rob Herring (Arm)
2026-07-11 6:01 ` [PATCH 10/16] ASoC: omap3pandora: Rewrite sound card driver as a platform driver with DT H. Nikolaus Schaller
2026-07-11 6:15 ` sashiko-bot [this message]
2026-07-11 6:01 ` [PATCH 11/16] ARM: dts: omap3-pandora-common: Enable audio in/out (mcbsp4/2) H. Nikolaus Schaller
2026-07-11 6:17 ` sashiko-bot
2026-07-11 6:01 ` [PATCH 12/16] arm: dts: omap3pandora: Add device node for PCM1773 codec H. Nikolaus Schaller
2026-07-11 6:15 ` sashiko-bot
2026-07-11 6:02 ` [PATCH 13/16] arm: dts: omap3pandora: create new DT node for the sound card H. Nikolaus Schaller
2026-07-11 6:17 ` sashiko-bot
2026-07-11 6:02 ` [PATCH 14/16] arm: dts: omap3-pandora-common: backlight: switch to twl4030 pwm and pwm_bl H. Nikolaus Schaller
2026-07-11 6:15 ` sashiko-bot
2026-07-11 6:02 ` [PATCH 15/16] backlight: remove pandora_bl H. Nikolaus Schaller
2026-07-11 6:16 ` sashiko-bot
2026-07-11 6:02 ` [PATCH 16/16] arm: omap2: remove remaining pdata-quirks for pandora legacy devices H. Nikolaus Schaller
2026-07-11 6:13 ` 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=20260711061519.0D85B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hns@goldelico.com \
--cc=lee@kernel.org \
--cc=mfd@lists.linux.dev \
--cc=robh@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox