Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] sound/soc/sof:Use kmalloc_array instead of kmalloc
@ 2025-09-23 14:25 hariconscious
  2025-10-15 19:08 ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: hariconscious @ 2025-09-23 14:25 UTC (permalink / raw)
  To: lgirdwood, peter.ujfalusi, yung-chuan.liao, ranjani.sridharan,
	daniel.baluta, kai.vehmanen, pierre-louis.bossart
  Cc: shuah, broonie, perex, tiwai, sound-open-firmware, linux-sound,
	linux-kernel, HariKrishna Sagala

From: HariKrishna Sagala <hariconscious@gmail.com>

Documentation/process/deprecated.rst recommends to avoid the use of
kmalloc with dynamic size calculations due to the risk of them
overflowing. This could lead to values wrapping around and a
smaller allocation being made than the caller was expecting.

Replace kmalloc() with kmalloc_array()

Signed-off-by: HariKrishna Sagala <hariconscious@gmail.com>
---
 sound/soc/sof/ipc3-dtrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/sof/ipc3-dtrace.c b/sound/soc/sof/ipc3-dtrace.c
index e5c8fec173c4..6ec391fd39a9 100644
--- a/sound/soc/sof/ipc3-dtrace.c
+++ b/sound/soc/sof/ipc3-dtrace.c
@@ -126,7 +126,7 @@ static int trace_filter_parse(struct snd_sof_dev *sdev, char *string,
 		capacity += TRACE_FILTER_ELEMENTS_PER_ENTRY;
 		entry = strchr(entry + 1, entry_delimiter[0]);
 	}
-	*out = kmalloc(capacity * sizeof(**out), GFP_KERNEL);
+	*out = kmalloc_array(capacity, sizeof(**out), GFP_KERNEL);
 	if (!*out)
 		return -ENOMEM;
 
-- 
2.43.0


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

end of thread, other threads:[~2025-11-27 12:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23 14:25 [PATCH] sound/soc/sof:Use kmalloc_array instead of kmalloc hariconscious
2025-10-15 19:08 ` Mark Brown
2025-11-06  9:40   ` HariKrishna Sagala
2025-11-27  5:05     ` HariKrishna Sagala
2025-11-27 11:12       ` Mark Brown
2025-11-27 12:14         ` HariKrishna Sagala

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