public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] sound/soc/sof:Use kmalloc_array instead of kmalloc
@ 2025-10-03  4:58 hariconscious
  0 siblings, 0 replies; only message in thread
From: hariconscious @ 2025-10-03  4:58 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>
---

Resending the patch

 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] only message in thread

only message in thread, other threads:[~2025-10-03  4:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-03  4:58 [PATCH RESEND] sound/soc/sof:Use kmalloc_array instead of kmalloc hariconscious

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