[PATCH] ASoC: amd: acp: Fix potential null pointer dereference of "adata"

Luo Yifan posted 1 patch 2 weeks, 4 days ago
sound/soc/amd/acp/acp-platform.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] ASoC: amd: acp: Fix potential null pointer dereference of "adata"
Posted by Luo Yifan 2 weeks, 4 days ago
The condition `!adata` indicates a possible null pointer dereference
for the "adata" parameter. To address this, the access to "adata"
members has been moved after the null check to ensure safer handling.

Signed-off-by: Luo Yifan <luoyifan@cmss.chinamobile.com>
---
 sound/soc/amd/acp/acp-platform.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/amd/acp/acp-platform.c b/sound/soc/amd/acp/acp-platform.c
index 3a7a467b7..2acb08073 100644
--- a/sound/soc/amd/acp/acp-platform.c
+++ b/sound/soc/amd/acp/acp-platform.c
@@ -137,7 +137,7 @@ EXPORT_SYMBOL_NS_GPL(acp_machine_select, SND_SOC_ACP_COMMON);
 static irqreturn_t i2s_irq_handler(int irq, void *data)
 {
 	struct acp_dev_data *adata = data;
-	struct acp_resource *rsrc = adata->rsrc;
+	struct acp_resource *rsrc;
 	struct acp_stream *stream;
 	u16 i2s_flag = 0;
 	u32 ext_intr_stat, ext_intr_stat1;
@@ -145,6 +145,8 @@ static irqreturn_t i2s_irq_handler(int irq, void *data)
 	if (!adata)
 		return IRQ_NONE;
 
+	rsrc = adata->rsrc;
+
 	if (adata->rsrc->no_of_ctrls == 2)
 		ext_intr_stat1 = readl(ACP_EXTERNAL_INTR_STAT(adata, (rsrc->irqp_used - 1)));
 
-- 
2.27.0
Re: [PATCH] ASoC: amd: acp: Fix potential null pointer dereference of "adata"
Posted by Mark Brown 1 week, 5 days ago
On Wed, Nov 06, 2024 at 01:57:20PM +0800, Luo Yifan wrote:
> The condition `!adata` indicates a possible null pointer dereference
> for the "adata" parameter. To address this, the access to "adata"
> members has been moved after the null check to ensure safer handling.

This doesn't apply against current code, please check and resend.
Re: [PATCH] ASoC: amd: acp: Fix potential null pointer dereference of "adata"
Posted by Luo Yifan 1 week, 5 days ago
Hello, the current code has already fixed this, so the patch isn't
needed anymore. Please just ignore it.