Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: <kuninori.morimoto.gx@renesas.com>, <tony.luck@intel.com>,
	<amadeuszx.slawinski@linux.intel.com>,
	<linux-sound@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<stable@vger.kernel.org>, <liam.r.girdwood@linux.intel.com>,
	<peter.ujfalusi@linux.intel.com>,
	<yung-chuan.liao@linux.intel.com>,
	<ranjani.sridharan@linux.intel.com>,
	<kai.vehmanen@linux.intel.com>, <pierre-louis.bossart@linux.dev>,
	<broonie@kernel.org>, <perex@perex.cz>, <tiwai@suse.com>
Subject: Re: [PATCH] ASoC: Intel: avs: Add null pointer check for es8366
Date: Wed, 14 May 2025 15:48:27 +0200	[thread overview]
Message-ID: <ac635ae5-5486-4243-901d-701f2ee90809@intel.com> (raw)
In-Reply-To: <20250514133409.713-1-vulab@iscas.ac.cn>

On 2025-05-14 3:34 PM, Wentao Liang wrote:
> The avs_card_suspend_pre() and avs_card_resume_post() in es8336
> calls the snd_soc_card_get_codec_dai(), but does not check its return
> value which is a null pointer if the function fails. This can result
> in a null pointer dereference. A proper implementation can be found
> in acp5x_nau8821_hw_params() and card_suspend_pre().
> 
> Add a null pointer check for snd_soc_card_get_codec_dai() to avoid null
> pointer dereference when the function fails.
> 
> Fixes: 32e40c8d6ff9 ("ASoC: Intel: avs: Add es8336 machine board")
> Cc: stable@vger.kernel.org # v6.6
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>   sound/soc/intel/avs/boards/es8336.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/sound/soc/intel/avs/boards/es8336.c b/sound/soc/intel/avs/boards/es8336.c
> index 426ce37105ae..e31cc656f076 100644
> --- a/sound/soc/intel/avs/boards/es8336.c
> +++ b/sound/soc/intel/avs/boards/es8336.c
> @@ -243,6 +243,9 @@ static int avs_card_suspend_pre(struct snd_soc_card *card)
>   {
>   	struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, ES8336_CODEC_DAI);
>   
> +	if (!codec_dai)
> +		return -EINVAL;
> +
>   	return snd_soc_component_set_jack(codec_dai->component, NULL, NULL);
>   }
>   
> @@ -251,6 +254,9 @@ static int avs_card_resume_post(struct snd_soc_card *card)
>   	struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, ES8336_CODEC_DAI);
>   	struct avs_card_drvdata *data = snd_soc_card_get_drvdata(card);
>   
> +	if (!codec_dai)
> +		return -EINVAL;
> +
>   	return snd_soc_component_set_jack(codec_dai->component, &data->jack, NULL);
>   }

Hi Wentao,

Thank you for the contribution but we do not NULL-check the result of 
snd_soc_card_get_codec_dai() wrapper. The machine board driver (also 
called sound card driver) never reaches this area if all the CPU and 
CODEC DAIs haven't been previously accounted for and verified. Flooding 
sound/soc/ with such checks is a waste of LOCs.

NACK

Kind regards,
Czarek

      reply	other threads:[~2025-05-14 13:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-14 13:34 [PATCH] ASoC: Intel: avs: Add null pointer check for es8366 Wentao Liang
2025-05-14 13:48 ` 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=ac635ae5-5486-4243-901d-701f2ee90809@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=kuninori.morimoto.gx@renesas.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=ranjani.sridharan@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.com \
    --cc=tony.luck@intel.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