From: Jiri Slaby <jslaby@suse.cz>
To: Gen Zhang <blackgod016574@gmail.com>,
broonie@kernel.org, lgirdwood@gmail.com, perex@perex.cz,
wen.yang99@zte.com.cn
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] wcd9335: fix a incorrect use of kstrndup()
Date: Wed, 5 Jun 2019 06:57:02 +0200 [thread overview]
Message-ID: <7573d8ce-7160-39b1-8901-be9155c451a1@suse.cz> (raw)
In-Reply-To: <20190529015305.GA4700@zhanggen-UX430UQ>
On 29. 05. 19, 3:53, Gen Zhang wrote:
> 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."
Except the size is not known exactly. It is at most 15, not 15. Right?
> 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;
>
thanks,
--
js
suse labs
next prev parent reply other threads:[~2019-06-05 4:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Jiri Slaby [this message]
2019-06-18 23:05 ` [PATCH] wcd9335: fix a incorrect use of kstrndup() Tyler Hicks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7573d8ce-7160-39b1-8901-be9155c451a1@suse.cz \
--to=jslaby@suse.cz \
--cc=alsa-devel@alsa-project.org \
--cc=blackgod016574@gmail.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=wen.yang99@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®