]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ASoC: amd: acp: Fix incorrect retrival of acp_chip_info
authorVenkata Prasad Potturu <venkataprasad.potturu@amd.com>
Wed, 10 Sep 2025 17:13:59 +0000 (22:43 +0530)
committerMark Brown <broonie@kernel.org>
Mon, 15 Sep 2025 11:49:11 +0000 (12:49 +0100)
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>
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>
sound/soc/amd/acp/acp-i2s.c

index 617690362ad75cfe930d383bd74b469542dc694f..4ba0a66981ea9d36c2382ce5a42420af950eff7e 100644 (file)
@@ -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;