* [PATCH] sound:emu10k1:Use kmemdup instead of duplicating its function
@ 2018-12-24 8:42 huang.zijiang
2019-01-01 8:51 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: huang.zijiang @ 2018-12-24 8:42 UTC (permalink / raw)
To: perex
Cc: tiwai, keescook, colin.king, w, alsa-devel, linux-kernel,
xue.zhihong, wang.yi59, huang.zijiang
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));
if (in_kernel) {
memcpy(tlv + 2, (__force void *)(_tlv + 2), data[1]);
} else if (copy_from_user(tlv + 2, _tlv + 2, data[1])) {
--
1.8.3.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] sound:emu10k1:Use kmemdup instead of duplicating its function
2018-12-24 8:42 [PATCH] sound:emu10k1:Use kmemdup instead of duplicating its function huang.zijiang
@ 2019-01-01 8:51 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2019-01-01 8:51 UTC (permalink / raw)
To: huang.zijiang
Cc: perex, w, alsa-devel, colin.king, keescook, linux-kernel,
wang.yi59, xue.zhihong
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-01 8:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-24 8:42 [PATCH] sound:emu10k1:Use kmemdup instead of duplicating its function huang.zijiang
2019-01-01 8:51 ` Takashi Iwai
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®