From: Wen Yang Date: Thu, 6 Dec 2018 12:29:10 +0000 (-0500) Subject: media: siano: Use kmemdup instead of duplicating its function X-Git-Tag: v5.0-rc1~182^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f4bb10857e22a657e6c8cca5d1d54b641e94628;p=thirdparty%2Fkernel%2Flinux.git media: siano: Use kmemdup instead of duplicating its function kmemdup has implemented the function that kmalloc() + memcpy(). We prefer to kmemdup rather than code opened implementation. This issue was detected with the help of coccinelle. Signed-off-by: Wen Yang CC: Tomoki Sekiyama CC: linux-kernel@vger.kernel.org Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c index be3634407f1f3..2ffded08407b8 100644 --- a/drivers/media/usb/siano/smsusb.c +++ b/drivers/media/usb/siano/smsusb.c @@ -225,10 +225,9 @@ static int smsusb_sendrequest(void *context, void *buffer, size_t size) return -ENOENT; } - phdr = kmalloc(size, GFP_KERNEL); + phdr = kmemdup(buffer, size, GFP_KERNEL); if (!phdr) return -ENOMEM; - memcpy(phdr, buffer, size); pr_debug("sending %s(%d) size: %d\n", smscore_translate_msg(phdr->msg_type), phdr->msg_type,