Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
Cc: <Vijendar.Mukunda@amd.com>, <Basavaraj.Hiregoudar@amd.com>,
	<Sunil-kumar.Dommati@amd.com>, <syed.sabakareem@amd.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
	Daniel Baluta <daniel.baluta@nxp.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..."
	<linux-sound@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>, <broonie@kernel.org>,
	<alsa-devel@alsa-project.org>
Subject: Re: [PATCH v2] ASoC: amd: acp: Fix incorrect retrival of acp_chip_info
Date: Thu, 11 Sep 2025 09:40:59 +0200	[thread overview]
Message-ID: <73a46879-b1be-4668-8447-17786b3b1d57@intel.com> (raw)
In-Reply-To: <20250910171419.3682468-1-venkataprasad.potturu@amd.com>

On 2025-09-10 7:13 PM, Venkata Prasad Potturu wrote:
> Use dev_get_drvdata(dev->parent) instead of dev_get_platdata(dev)
> to correctly obtain acp_chip_info members in the acp I2S driver.
> Previously, some members were not updated properly due to incorrect
> data access, which could potentially lead to null pointer
> dereferences.
> 
> This issue was missed in the earlier commit
> ("ASoC: amd: acp: Fix NULL pointer deref in acp_i2s_set_tdm_slot"),
> which only addressed set_tdm_slot(). This change ensures that all
> relevant functions correctly retrieve acp_chip_info, preventing
> further null pointer dereference issues.
> 
> Fixes: e3933683b25e ("ASoC: amd: acp: Remove redundant acp_dev_data structure")
> 
> Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>

Thank you for the update, the patch looks better.

Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>

> ---
> 
> Changes since v1:
> - Update the commit description.
> 
>   sound/soc/amd/acp/acp-i2s.c | 11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/sound/soc/amd/acp/acp-i2s.c b/sound/soc/amd/acp/acp-i2s.c
> index 617690362ad7..4ba0a66981ea 100644
> --- a/sound/soc/amd/acp/acp-i2s.c
> +++ b/sound/soc/amd/acp/acp-i2s.c
> @@ -73,7 +73,7 @@ static int acp_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
>   			   unsigned int fmt)
>   {
>   	struct device *dev = cpu_dai->component->dev;
> -	struct acp_chip_info *chip = dev_get_platdata(dev);
> +	struct acp_chip_info *chip = dev_get_drvdata(dev->parent);
>   	int mode;
>   
>   	mode = fmt & SND_SOC_DAIFMT_FORMAT_MASK;
> @@ -199,7 +199,7 @@ static int acp_i2s_hwparams(struct snd_pcm_substream *substream, struct snd_pcm_
>   	u32 reg_val, fmt_reg, tdm_fmt;
>   	u32 lrclk_div_val, bclk_div_val;
>   
> -	chip = dev_get_platdata(dev);
> +	chip = dev_get_drvdata(dev->parent);
>   	rsrc = chip->rsrc;
>   
>   	/* These values are as per Hardware Spec */
> @@ -386,7 +386,7 @@ static int acp_i2s_trigger(struct snd_pcm_substream *substream, int cmd, struct
>   {
>   	struct acp_stream *stream = substream->runtime->private_data;
>   	struct device *dev = dai->component->dev;
> -	struct acp_chip_info *chip = dev_get_platdata(dev);
> +	struct acp_chip_info *chip = dev_get_drvdata(dev->parent);
>   	struct acp_resource *rsrc = chip->rsrc;
>   	u32 val, period_bytes, reg_val, ier_val, water_val, buf_size, buf_reg;
>   
> @@ -516,14 +516,13 @@ static int acp_i2s_trigger(struct snd_pcm_substream *substream, int cmd, struct
>   static int acp_i2s_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
>   {
>   	struct device *dev = dai->component->dev;
> -	struct acp_chip_info *chip = dev_get_platdata(dev);
> +	struct acp_chip_info *chip = dev_get_drvdata(dev->parent);
>   	struct acp_resource *rsrc = chip->rsrc;
>   	struct acp_stream *stream = substream->runtime->private_data;
>   	u32 reg_dma_size = 0, reg_fifo_size = 0, reg_fifo_addr = 0;
>   	u32 phy_addr = 0, acp_fifo_addr = 0, ext_int_ctrl;
>   	unsigned int dir = substream->stream;
>   
> -	chip = dev_get_platdata(dev);
>   	switch (dai->driver->id) {
>   	case I2S_SP_INSTANCE:
>   		if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
> @@ -632,7 +631,7 @@ static int acp_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_d
>   {
>   	struct acp_stream *stream = substream->runtime->private_data;
>   	struct device *dev = dai->component->dev;
> -	struct acp_chip_info *chip = dev_get_platdata(dev);
> +	struct acp_chip_info *chip = dev_get_drvdata(dev->parent);
>   	struct acp_resource *rsrc = chip->rsrc;
>   	unsigned int dir = substream->stream;
>   	unsigned int irq_bit = 0;


  reply	other threads:[~2025-09-11  7:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-10 17:13 [PATCH v2] ASoC: amd: acp: Fix incorrect retrival of acp_chip_info Venkata Prasad Potturu
2025-09-11  7:40 ` Cezary Rojewski [this message]
2025-09-16 12:08 ` Mark Brown

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=73a46879-b1be-4668-8447-17786b3b1d57@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=Basavaraj.Hiregoudar@amd.com \
    --cc=Sunil-kumar.Dommati@amd.com \
    --cc=Vijendar.Mukunda@amd.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peterz@infradead.org \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=syed.sabakareem@amd.com \
    --cc=tiwai@suse.com \
    --cc=venkataprasad.potturu@amd.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