diff mbox series

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

Message ID 20241106055720.208057-1-luoyifan@cmss.chinamobile.com (mailing list archive)
State New
Headers show
Series ASoC: amd: acp: Fix potential null pointer dereference of "adata" | expand

Commit Message

Luo Yifan Nov. 6, 2024, 5:57 a.m. UTC
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(-)

Comments

Mark Brown Nov. 11, 2024, 2:26 p.m. UTC | #1
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.
Luo Yifan Nov. 12, 2024, 2:16 a.m. UTC | #2
Hello, the current code has already fixed this, so the patch isn't
needed anymore. Please just ignore it.
diff mbox series

Patch

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)));