[PATCH] ASoC: sdw_utils: Fix potential NULL pointer deref in is_sdca_endpoint_present()

From: Thorsten Blum
Date: Tue Jun 10 2025 - 06:33:50 EST


Check the return value of kzalloc() and exit early to avoid a potential
NULL pointer dereference.

Cc: stable@xxxxxxxxxxxxxxx
Fixes: 4f8ef33dd44a ("ASoC: soc_sdw_utils: skip the endpoint that doesn't present")
Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
---
sound/soc/sdw_utils/soc_sdw_utils.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c
index 30f84f4e7637..b70cb3793d8f 100644
--- a/sound/soc/sdw_utils/soc_sdw_utils.c
+++ b/sound/soc/sdw_utils/soc_sdw_utils.c
@@ -1180,6 +1180,8 @@ static int is_sdca_endpoint_present(struct device *dev,
int i;

dlc = kzalloc(sizeof(*dlc), GFP_KERNEL);
+ if (!dlc)
+ return -ENOMEM;

adr_end = &adr_dev->endpoints[end_index];
dai_info = &codec_info->dais[adr_end->num];
--
2.49.0