wcd9335: fix a incorrect use of kstrndup()
authorGen Zhang <blackgod016574@gmail.com>
Wed, 29 May 2019 01:53:05 +0000 (09:53 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 29 May 2019 15:35:35 +0000 (16:35 +0100)
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>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wcd9335.c

index a04a7cedd99dee6a7272b3ab324405048b80de1b..85737fe544746903e9df54fcb7a3169de6ae6690 100644 (file)
@@ -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;