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

Zhang Heng posted 1 patch 11 months ago
sound/soc/sof/topology.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH v2] ASoC: SOF: topology: Use krealloc_array() to replace krealloc()
Posted by Zhang Heng 11 months ago
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 --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;
-- 
2.47.1
Re: [PATCH v2] ASoC: SOF: topology: Use krealloc_array() to replace krealloc()
Posted by Mark Brown 10 months, 2 weeks ago
On Fri, 17 Jan 2025 09:43:43 +0800, Zhang Heng wrote:
> Use krealloc_array() to replace krealloc() with multiplication.
> krealloc_array() has multiply overflow check, which will be safer.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: SOF: topology: Use krealloc_array() to replace krealloc()
      commit: a05143a8f713d9ae6abc41141dac52c66fca8b06

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark