Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ASoC: SOF: topology: Use krealloc_array() to replace krealloc()
@ 2025-01-14  1:28 Zhang Heng
  2025-01-15  9:03 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Heng @ 2025-01-14  1:28 UTC (permalink / raw)
  To: lgirdwood, peter.ujfalusi, yung-chuan.liao, ranjani.sridharan,
	daniel.baluta, kai.vehmanen, pierre-louis.bossart, broonie, perex,
	tiwai
  Cc: sound-open-firmware, linux-sound, linux-kernel, Zhang Heng

Use krealloc_array() to replace krealloc() with multiplication.
krealloc_array() has multiply overflow check, which will be safer.

Signed-off-by: Zhang Heng <zhangheng@kylinos.cn>
---
 sound/soc/sof/topology.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index b3fca5fd87d6..b13b1dafa71b 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -1269,8 +1269,8 @@ static int sof_widget_parse_tokens(struct snd_soc_component *scomp, struct snd_s
 			struct snd_sof_tuple *new_tuples;
 
 			num_tuples += token_list[object_token_list[i]].count * (num_sets - 1);
-			new_tuples = krealloc(swidget->tuples,
-					      sizeof(*new_tuples) * num_tuples, GFP_KERNEL);
+			new_tuples = krealloc_array(swidget->tuples,
+						    sizeof(*new_tuples), num_tuples, GFP_KERNEL);
 			if (!new_tuples) {
 				ret = -ENOMEM;
 				goto err;
-- 
2.45.2


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

end of thread, other threads:[~2025-01-15  9:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-14  1:28 [PATCH] ASoC: SOF: topology: Use krealloc_array() to replace krealloc() Zhang Heng
2025-01-15  9:03 ` kernel test robot

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