Skip to contentSkip to conversation

ASoC: SDCA: bug fix while parsing mipi-sdca-control-cn-list

PATCH Superseded Niranjan H Y 2 participants 2 messages Nov 10, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: SDCA: bug fix while parsing mipi-sdca-control-cn-list

"struct sdca_control" declares "values" field as integer array. But the memory allocated to it is of char array. This causes crash for sdca_parse_function API. This patch addresses the issue by allocating correct data size.

---
 sound/soc/sdca/sdca_functions.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/sdca/sdca_functions.c +2 -1
index b2e3fab9b..6975c71a9 100644
@@ -950,7 +950,8 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti
 		return ret;
 	}
 
-	control->values = devm_kzalloc(dev, hweight64(control->cn_list), GFP_KERNEL);
+	control->values = devm_kzalloc(dev, hweight64(control->cn_list) * sizeof(int),
+				       GFP_KERNEL);
 	if (!control->values)
 		return -ENOMEM;
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 7 lines · Niranjan H Y

"struct sdca_control" declares "values" field as integer array. But the memory allocated to it is of char array. This causes crash for sdca_parse_function API. This patch addresses the issue by allocating correct data size.

---

Thanks very much for spotting this.

Quoted 8 lines
 sound/soc/sdca/sdca_functions.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/sdca/sdca_functions.c +0 -0
index b2e3fab9b..6975c71a9 100644

sound/soc/sdca/sdca_functions.c static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti · line 954

Quoted 6 lines
sound/soc/sdca/sdca_functions.c +2 -1
@@ -950,7 +950,8 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti
 		return ret;
 	}
 
-	control->values = devm_kzalloc(dev, hweight64(control->cn_list), GFP_KERNEL);
+	control->values = devm_kzalloc(dev, hweight64(control->cn_list) * sizeof(int),
+				       GFP_KERNEL);

Should probably switch to devm_kcalloc, rather than doing the multiply manually.

Thanks,
Charles

Quoted 6 lines
sound/soc/sdca/sdca_functions.c +0 -0
 	if (!control->values)
 		return -ENOMEM;
 
Signature · 1 line
2.25.1