Revert "wcd9335: fix a incorrect use of kstrndup()"
diff mbox series

Message ID 20190612133040.5kgtio7gidxx64gh@xylophone.i.decadent.org.uk
State New
Headers show
Series
  • Revert "wcd9335: fix a incorrect use of kstrndup()"
Related show

Commit Message

Ben Hutchings June 12, 2019, 1:30 p.m. UTC
This reverts commit a54988113985ca22e414e132054f234fc8a92604.
The strings being duplicated are not fixed-length, so kstrndup()
is the correct function to use.

Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
---
 sound/soc/codecs/wcd9335.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Gen Zhang June 12, 2019, 1:34 p.m. UTC | #1
On Wed, Jun 12, 2019 at 02:30:40PM +0100, Ben Hutchings wrote:
> This reverts commit a54988113985ca22e414e132054f234fc8a92604.
> The strings being duplicated are not fixed-length, so kstrndup()
> is the correct function to use.
> 
> Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
> ---
>  sound/soc/codecs/wcd9335.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
> index 85737fe54474..a04a7cedd99d 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 = kmemdup_nul(w->name, 15, GFP_KERNEL);
> +	widget_name = kstrndup(w->name, 15, GFP_KERNEL);
>  	if (!widget_name)
>  		return -ENOMEM;
>  
> -- 
> Ben Hutchings, Software Developer                         Codethink Ltd
> https://www.codethink.co.uk/                 Dale House, 35 Dale Street
>                                      Manchester, M1 2HF, United Kingdom
> 
OMG! There is someone following what I was doing these days...
Kind of peculiar
Gen Zhang June 12, 2019, 2:05 p.m. UTC | #2
On Wed, Jun 12, 2019 at 02:30:40PM +0100, Ben Hutchings wrote:
> This reverts commit a54988113985ca22e414e132054f234fc8a92604.
> The strings being duplicated are not fixed-length, so kstrndup()
> is the correct function to use.
> 
> Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
> ---
>  sound/soc/codecs/wcd9335.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
> index 85737fe54474..a04a7cedd99d 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 = kmemdup_nul(w->name, 15, GFP_KERNEL);
> +	widget_name = kstrndup(w->name, 15, GFP_KERNEL);
>  	if (!widget_name)
>  		return -ENOMEM;
>  
> -- 
> Ben Hutchings, Software Developer                         Codethink Ltd
> https://www.codethink.co.uk/                 Dale House, 35 Dale Street
>                                      Manchester, M1 2HF, United Kingdom
> 
BTW, why don't you use ben@decadent.org.uk this time...
I am just curious:-)
No need to reply

Thanks
Gen

Patch
diff mbox series

diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
index 85737fe54474..a04a7cedd99d 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 = kmemdup_nul(w->name, 15, GFP_KERNEL);
+	widget_name = kstrndup(w->name, 15, GFP_KERNEL);
 	if (!widget_name)
 		return -ENOMEM;