Skip to content

Commit 65c5cfb

Browse files
Venkata-Prasad-Potturugregkh
authored andcommitted
ASoC: amd: acp: Fix incorrect retrival of acp_chip_info
[ Upstream commit d7871f4 ] 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 <[email protected]> Reviewed-by: Cezary Rojewski <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent f722977 commit 65c5cfb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

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

7878
mode = fmt & SND_SOC_DAIFMT_FORMAT_MASK;
@@ -196,7 +196,7 @@ static int acp_i2s_hwparams(struct snd_pcm_substream *substream, struct snd_pcm_
196196
u32 reg_val, fmt_reg, tdm_fmt;
197197
u32 lrclk_div_val, bclk_div_val;
198198

199-
chip = dev_get_platdata(dev);
199+
chip = dev_get_drvdata(dev->parent);
200200
rsrc = chip->rsrc;
201201

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

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

523-
chip = dev_get_platdata(dev);
524523
switch (dai->driver->id) {
525524
case I2S_SP_INSTANCE:
526525
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -629,7 +628,7 @@ static int acp_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_d
629628
{
630629
struct acp_stream *stream = substream->runtime->private_data;
631630
struct device *dev = dai->component->dev;
632-
struct acp_chip_info *chip = dev_get_platdata(dev);
631+
struct acp_chip_info *chip = dev_get_drvdata(dev->parent);
633632
struct acp_resource *rsrc = chip->rsrc;
634633
unsigned int dir = substream->stream;
635634
unsigned int irq_bit = 0;

0 commit comments

Comments
 (0)