diff mbox series

[v2] ASoC: SOF: topology: Use krealloc_array() to replace krealloc()

Message ID 20250117014343.451503-1-zhangheng@kylinos.cn (mailing list archive)
State New
Headers show
Series [v2] ASoC: SOF: topology: Use krealloc_array() to replace krealloc() | expand

Commit Message

Zhang Heng Jan. 17, 2025, 1:43 a.m. UTC
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>
---

Changes in v2:
- Fix Warning [1].
- submitting the patch again would be more appropriate.

[1]: https://lore.kernel.org/all/202501151630.VyzkV2xo-lkp@intel.com/

 sound/soc/sof/topology.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 688cc7ac1714..dc9cb8324067 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -1273,8 +1273,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,
+						    num_tuples, sizeof(*new_tuples), GFP_KERNEL);
 			if (!new_tuples) {
 				ret = -ENOMEM;
 				goto err;