mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] wcd9335: fix a incorrect use of kstrndup()
@ 2019-05-29  1:53 Gen Zhang
  2019-05-29 15:45 ` Applied "wcd9335: fix a incorrect use of kstrndup()" to the asoc tree Mark Brown
  2019-06-05  4:57 ` [PATCH] wcd9335: fix a incorrect use of kstrndup() Jiri Slaby
  0 siblings, 2 replies; 4+ messages in thread
From: Gen Zhang @ 2019-05-29  1:53 UTC (permalink / raw)
  To: broonie, lgirdwood, perex, wen.yang99; +Cc: alsa-devel, linux-kernel

In wcd9335_codec_enable_dec(), 'widget_name' is allocated by kstrndup().
However, according to doc: "Note: Use kmemdup_nul() instead if the size
is known exactly." So we should use kmemdup_nul() here instead of
kstrndup().

Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
---
diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
index a04a7ce..85737fe 100644
--- a/sound/soc/codecs/wcd9335.c
+++ b/sound/soc/codecs/wcd9335.c
@@ -2734,7 +2734,7 @@ static int wcd9335_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;
 
---

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

end of thread, other threads:[~2019-06-18 23:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-29  1:53 [PATCH] wcd9335: fix a incorrect use of kstrndup() Gen Zhang
2019-05-29 15:45 ` Applied "wcd9335: fix a incorrect use of kstrndup()" to the asoc tree Mark Brown
2019-06-05  4:57 ` [PATCH] wcd9335: fix a incorrect use of kstrndup() Jiri Slaby
2019-06-18 23:05   ` Tyler Hicks

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

all inboxes | Powered by JetHome®