public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sound: soc: wcd934x: fix an incorrect use of kstrndup()
@ 2024-01-18  7:52 Fullway Wang
  2024-01-29 21:32 ` Mark Brown
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Fullway Wang @ 2024-01-18  7:52 UTC (permalink / raw)
  To: broonie, srinivas.kandagatla, bgoswami, tiwai
  Cc: linux-sound, linux-kernel, fullwaywang, Fullway Wang

In wcd934x_codec_enable_dec(), kstrndup() is used to alloc memory.
However, kmemdup_nul() should be used instead with the size known.

This is similar to CVE-2019-12454 which was fixed in commit
a549881.

Signed-off-by: Fullway Wang <fullwaywang@outlook.com>
---
 sound/soc/codecs/wcd934x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
index 1b6e376f3833..4565a0e1877f 100644
--- a/sound/soc/codecs/wcd934x.c
+++ b/sound/soc/codecs/wcd934x.c
@@ -4990,7 +4990,7 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w,
 	char *dec;
 	u8 hpf_coff_freq;
 
-	widget_name = kstrndup(w->name, 15, GFP_KERNEL);
+	widget_name = kmemdup_nul(w->name, 15, GFP_KERNEL);
 	if (!widget_name)
 		return -ENOMEM;
 
-- 
2.39.3 (Apple Git-145)


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

end of thread, other threads:[~2024-02-01 12:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-18  7:52 [PATCH] sound: soc: wcd934x: fix an incorrect use of kstrndup() Fullway Wang
2024-01-29 21:32 ` Mark Brown
2024-01-30  9:56 ` Amadeusz Sławiński
2024-01-30 15:43 ` Mark Brown
2024-02-01  9:04   ` Amadeusz Sławiński
2024-02-01 12:31     ` Mark Brown

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