Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH v1] ASoC: SDCA: bug fix while parsing mipi-sdca-control-cn-list
@ 2025-11-10 13:00 Niranjan H Y
  2025-11-10 13:48 ` Charles Keepax
  0 siblings, 1 reply; 2+ messages in thread
From: Niranjan H Y @ 2025-11-10 13:00 UTC (permalink / raw)
  To: alsa-devel
  Cc: broonie, ckeepax, mstrozek, yung-chuan.liao, linux-sound,
	lgirdwood, perex, tiwai, cezary.rojewski, peter.ujfalusi,
	ranjani.sridharan, kai.vehmanen, pierre-louis.bossart, navada,
	shenghao-ding, v-hampiholi, baojun.xu, dan.carpenter,
	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.

Signed-off-by: Niranjan H Y <niranjan.hy@ti.com>
---
 sound/soc/sdca/sdca_functions.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c
index b2e3fab9b..6975c71a9 100644
--- a/sound/soc/sdca/sdca_functions.c
+++ b/sound/soc/sdca/sdca_functions.c
@@ -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;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] ASoC: SDCA: bug fix while parsing mipi-sdca-control-cn-list
  2025-11-10 13:00 [PATCH v1] ASoC: SDCA: bug fix while parsing mipi-sdca-control-cn-list Niranjan H Y
@ 2025-11-10 13:48 ` Charles Keepax
  0 siblings, 0 replies; 2+ messages in thread
From: Charles Keepax @ 2025-11-10 13:48 UTC (permalink / raw)
  To: Niranjan H Y
  Cc: alsa-devel, broonie, mstrozek, yung-chuan.liao, linux-sound,
	lgirdwood, perex, tiwai, cezary.rojewski, peter.ujfalusi,
	ranjani.sridharan, kai.vehmanen, pierre-louis.bossart, navada,
	shenghao-ding, v-hampiholi, baojun.xu, dan.carpenter

On Mon, Nov 10, 2025 at 06:30:58PM +0530, Niranjan H Y wrote:
> "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.
> 
> Signed-off-by: Niranjan H Y <niranjan.hy@ti.com>
> ---

Thanks very much for spotting this.

>  sound/soc/sdca/sdca_functions.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c
> index b2e3fab9b..6975c71a9 100644
> --- a/sound/soc/sdca/sdca_functions.c
> +++ b/sound/soc/sdca/sdca_functions.c
> @@ -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

>  	if (!control->values)
>  		return -ENOMEM;
>  
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-10 13:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-10 13:00 [PATCH v1] ASoC: SDCA: bug fix while parsing mipi-sdca-control-cn-list Niranjan H Y
2025-11-10 13:48 ` Charles Keepax

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox