From: sashiko-bot@kernel.org
To: "Chancel Liu" <chancel.liu@nxp.com>
Cc: robh@kernel.org, imx@lists.linux.dev, Frank.Li@kernel.org,
conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 2/3] ASoC: imx-rpmsg: Support headphone jack detection
Date: Tue, 26 May 2026 06:31:10 +0000 [thread overview]
Message-ID: <20260526063110.EBEA31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260526053815.140008-3-chancel.liu@nxp.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Headphone jack is initialized after the sound card is fully registered, causing multiple fatal issues including broken jack registration, kernel bugs, and TOCTOU races with userspace.
- [Medium] The patch uses `simple_util_init_jack()` but fails to select its Kconfig dependency, leading to linker errors.
--
commit 23df7e137d741b3d9989cc72e4eb7cee017f18a1
Author: Chancel Liu <chancel.liu@nxp.com>
ASoC: imx-rpmsg: Support headphone jack detection
This commit adds headphone jack detection support for i.MX RPMSG audio cards.
It uses simple_util_init_jack() to register a headphone jack with GPIO-based
insertion detection when the hp-det-gpios property is present.
> diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
> index 40e0043cfe15e..9c1cf7045381a 100644
> --- a/sound/soc/fsl/imx-rpmsg.c
> +++ b/sound/soc/fsl/imx-rpmsg.c
> @@ -12,6 +12,7 @@
> #include <sound/control.h>
> #include <sound/pcm_params.h>
> #include <sound/soc-dapm.h>
> +#include <sound/simple_card_utils.h>
[Severity: Medium]
Is it possible to hit a linker error here if no other driver selects the
simple card utilities?
This patch uses simple_util_init_jack(), but doesn't appear to update the
Kconfig entry for SND_SOC_IMX_RPMSG to select SND_SIMPLE_CARD_UTILS. If
this driver is built in a configuration where no other selected options
pull in the simple card utilities, it might result in an undefined
reference error.
[ ... ]
> @@ -282,6 +284,12 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
> goto fail;
> }
>
> + if (of_property_present(np, "hp-det-gpios")) {
> + ret = simple_util_init_jack(&data->card, &data->hp_jack,
> + 1, NULL, "Headphone Jack");
[Severity: High]
Does initializing the headphone jack after devm_snd_soc_register_card() cause
issues with probe deferral?
If devm_snd_soc_register_card() defers due to a missing component, it queues
the card onto the unbind_card_list and returns 0. The driver then proceeds to
call simple_util_init_jack().
At this point, the snd_card pointer is NULL, which triggers a
snd_BUG_ON(!card) in snd_device_new() and returns -ENXIO. This return
value aborts the probe and breaks probe deferral completely.
Additionally, if the card registers synchronously, snd_card_register() is
called before the jack is initialized. Any ALSA devices added after
registration remain in the SNDRV_DEV_BUILD state and are not exposed to
userspace.
This order also creates a window where userspace daemons might probe the
sound card before the jack is created.
Could this jack initialization be moved to the card's late_probe callback
instead?
> + if (ret)
> + goto fail;
> + }
> fail:
> pdev->dev.of_node = NULL;
> return ret;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260526053815.140008-1-chancel.liu@nxp.com?part=2
next prev parent reply other threads:[~2026-05-26 6:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 5:38 [PATCH 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
2026-05-26 5:38 ` [PATCH 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property Chancel Liu
2026-05-26 5:38 ` [PATCH 2/3] ASoC: imx-rpmsg: Support headphone jack detection Chancel Liu
2026-05-26 6:31 ` sashiko-bot [this message]
2026-05-26 15:34 ` Mark Brown
2026-05-27 3:05 ` Chancel Liu (OSS)
2026-05-26 5:38 ` [PATCH 3/3] ASoC: imx-rpmsg: Set driver_name for snd_soc_card Chancel Liu
2026-05-28 2:07 ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Chancel Liu
2026-05-28 2:07 ` [PATCH v2 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property Chancel Liu
2026-05-28 2:07 ` [PATCH v2 2/3] ASoC: imx-rpmsg: Support headphone jack detection Chancel Liu
2026-05-28 3:01 ` sashiko-bot
2026-05-28 2:07 ` [PATCH v2 3/3] ASoC: imx-rpmsg: Set driver_name for snd_soc_card Chancel Liu
2026-05-28 14:12 ` [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support Andrew Lunn
2026-05-28 14:18 ` Mark Brown
2026-05-28 14:41 ` Andrew Lunn
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=20260526063110.EBEA31F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=chancel.liu@nxp.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=imx@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