mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: <hansg@kernel.org>, <kai.vehmanen@linux.intel.com>,
	<liam.r.girdwood@linux.intel.com>, <linux-kernel@vger.kernel.org>,
	<linux-sound@vger.kernel.org>, <perex@perex.cz>,
	<peter.ujfalusi@linux.intel.com>,
	<pierre-louis.bossart@linux.dev>, <tiwai@suse.com>,
	<yung-chuan.liao@linux.intel.com>, <stable@vger.kernel.org>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH] ASoC: Intel: bytcr_rt5640: Fix use-after-free in snd_byt_rt5640_mc_probe()
Date: Fri, 18 Sep 2026 10:23:48 +0200	[thread overview]
Message-ID: <c4491e5b-c89d-4fe5-a4cb-554a07c980b9@intel.com> (raw)
In-Reply-To: <20260917170052.2163636-1-vulab@iscas.ac.cn>

On 9/17/2026 7:00 PM, Wentao Liang wrote:
> When the device found by name is not an i2c_client, the reference taken
> by bus_find_device_by_name() is dropped, but execution continues with
> the stale codec_dev pointer, which is stored in priv->codec_dev and
> dereferenced later in the probe.
> 
> The device is not usable as the codec, so return an error after dropping
> the reference.
> 
> Fixes: d48696b91552 ("ASoC: Intel: bytcr_rt5640: Add support for non ACPI instantiated codec")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  sound/soc/intel/boards/bytcr_rt5640.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
> index 40da3eea5fa7..557486c6f28d 100644
> --- a/sound/soc/intel/boards/bytcr_rt5640.c
> +++ b/sound/soc/intel/boards/bytcr_rt5640.c
> @@ -1764,6 +1764,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
>  			dev_err(dev, "Error '%s' is not an i2c_client\n",
>  				BYT_RT5640_FALLBACK_CODEC_DEV_NAME);
>  			put_device(codec_dev);
> +			return -ENODEV;

I haven't found any 'return -ENODEV' after a failing i2c_verify_client()
check.  Most ignore, one (drivers/hwmon/hwmon.c) ends with -EINVAL.

Given the description of i2c_verify_client() I'd argue -EINVAL is a
better candidate.

A sidetopic, not strongly related to the error code - after analyzing
snd_byt_rt5640_mc_probe() its seems the check could be skipped entirely
if the portion of the function - dependent on codec_dev - is moved to
ASoC e.g.: card->late_probe().


Kind regards,
Czarek

      reply	other threads:[~2026-09-18  8:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 17:00 Wentao Liang
2026-09-18  8:23 ` Cezary Rojewski [this message]

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=c4491e5b-c89d-4fe5-a4cb-554a07c980b9@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=broonie@kernel.org \
    --cc=hansg@kernel.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.com \
    --cc=vulab@iscas.ac.cn \
    --cc=yung-chuan.liao@linux.intel.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

all inboxes | Powered by JetHome®