Skip to content

Commit d7871f4

Browse files
Venkata-Prasad-Potturubroonie
authored andcommitted
ASoC: amd: acp: Fix incorrect retrival of acp_chip_info
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: e393368 ("ASoC: amd: acp: Remove redundant acp_dev_data structure") Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com> Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250910171419.3682468-1-venkataprasad.potturu@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 73caf2b commit d7871f4

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

sound/soc/amd/acp/acp-i2s.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static int acp_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
7373
unsigned int fmt)
7474
{
7575
struct device *dev = cpu_dai->component->dev;
76-
struct acp_chip_info *chip = dev_get_platdata(dev);
76+
struct acp_chip_info *chip = dev_get_drvdata(dev->parent);
7777
int mode;
7878

7979
mode = fmt & SND_SOC_DAIFMT_FORMAT_MASK;
@@ -199,7 +199,7 @@ static int acp_i2s_hwparams(struct snd_pcm_substream *substream, struct snd_pcm_
199199
u32 reg_val, fmt_reg, tdm_fmt;
200200
u32 lrclk_div_val, bclk_div_val;
201201

202-
chip = dev_get_platdata(dev);
202+
chip = dev_get_drvdata(dev->parent);
203203
rsrc = chip->rsrc;
204204

205205
/* These values are as per Hardware Spec */
@@ -386,7 +386,7 @@ static int acp_i2s_trigger(struct snd_pcm_substream *substream, int cmd, struct
386386
{
387387
struct acp_stream *stream = substream->runtime->private_data;
388388
struct device *dev = dai->component->dev;
389-
struct acp_chip_info *chip = dev_get_platdata(dev);
389+
struct acp_chip_info *chip = dev_get_drvdata(dev->parent);
390390
struct acp_resource *rsrc = chip->rsrc;
391391
u32 val, period_bytes, reg_val, ier_val, water_val, buf_size, buf_reg;
392392

@@ -516,14 +516,13 @@ static int acp_i2s_trigger(struct snd_pcm_substream *substream, int cmd, struct
516516
static int acp_i2s_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
517517
{
518518
struct device *dev = dai->component->dev;
519-
struct acp_chip_info *chip = dev_get_platdata(dev);
519+
struct acp_chip_info *chip = dev_get_drvdata(dev->parent);
520520
struct acp_resource *rsrc = chip->rsrc;
521521
struct acp_stream *stream = substream->runtime->private_data;
522522
u32 reg_dma_size = 0, reg_fifo_size = 0, reg_fifo_addr = 0;
523523
u32 phy_addr = 0, acp_fifo_addr = 0, ext_int_ctrl;
524524
unsigned int dir = substream->stream;
525525

526-
chip = dev_get_platdata(dev);
527526
switch (dai->driver->id) {
528527
case I2S_SP_INSTANCE:
529528
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -632,7 +631,7 @@ static int acp_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_d
632631
{
633632
struct acp_stream *stream = substream->runtime->private_data;
634633
struct device *dev = dai->component->dev;
635-
struct acp_chip_info *chip = dev_get_platdata(dev);
634+
struct acp_chip_info *chip = dev_get_drvdata(dev->parent);
636635
struct acp_resource *rsrc = chip->rsrc;
637636
unsigned int dir = substream->stream;
638637
unsigned int irq_bit = 0;

0 commit comments

Comments
 (0)