From: Takashi Iwai <tiwai@suse.de>
To: " huang.zijiang " <huang.zijiang@zte.com.cn>
Cc: <perex@perex.cz>, <w@1wt.eu>, <alsa-devel@alsa-project.org>,
<colin.king@canonical.com>, <keescook@chromium.org>,
<linux-kernel@vger.kernel.org>, <wang.yi59@zte.com.cn>,
<xue.zhihong@zte.com.cn>
Subject: Re: [PATCH] sound:emu10k1:Use kmemdup instead of duplicating its function
Date: Tue, 01 Jan 2019 09:51:53 +0100 [thread overview]
Message-ID: <s5hsgyciwuu.wl-tiwai@suse.de> (raw)
In-Reply-To: <1545640968-42357-1-git-send-email-huang.zijiang@zte.com.cn>
On Mon, 24 Dec 2018 09:42:48 +0100,
huang.zijiang wrote:
>
> From: "huang.zijiang" <huang.zijiang@zte.com.cn>
>
> kmemdup has implemented the function that kmalloc() and memcpy().
>
> Signed-off-by: huang.zijiang <huang.zijiang@zte.com.cn>
> ---
> sound/pci/emu10k1/emufx.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
> index 6ebe817..b4fe4c5 100644
> --- a/sound/pci/emu10k1/emufx.c
> +++ b/sound/pci/emu10k1/emufx.c
> @@ -671,10 +671,9 @@ static unsigned int *copy_tlv(const unsigned int __user *_tlv, bool in_kernel)
> return NULL;
> if (data[1] >= MAX_TLV_SIZE)
> return NULL;
> - tlv = kmalloc(data[1] + sizeof(data), GFP_KERNEL);
> + tlv = kmemdup(data, data[1] + sizeof(data), GFP_KERNEL);
> if (!tlv)
> return NULL;
> - memcpy(tlv, data, sizeof(data));
These changes are not equivalent, and rather dangerous, unfortunately.
The memcpy() performs only for sizeof(data), and in this case, it's
not the same size as the allocation above.
thanks,
Takashi
prev parent reply other threads:[~2019-01-01 8:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-24 8:42 huang.zijiang
2019-01-01 8:51 ` Takashi Iwai [this message]
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=s5hsgyciwuu.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=colin.king@canonical.com \
--cc=huang.zijiang@zte.com.cn \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=w@1wt.eu \
--cc=wang.yi59@zte.com.cn \
--cc=xue.zhihong@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®