diff mbox series

[4.19,2/5] media: siano: Use kmemdup instead of duplicating its function

Message ID 20191126134830.12747-2-lee.jones@linaro.org
State Superseded
Headers show
Series [4.19,1/5] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary | expand

Commit Message

Lee Jones Nov. 26, 2019, 1:48 p.m. UTC
From: Wen Yang <wen.yang99@zte.com.cn>


[ Upstream commit 188ba34e2bcfc9a23d301bd78e35bc1d5ad9ae5a ]

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 <wen.yang99@zte.com.cn>

CC: Tomoki Sekiyama <tomoki.sekiyama@gmail.com>
CC: linux-kernel@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

Signed-off-by: Lee Jones <lee.jones@linaro.org>

---
 drivers/media/usb/siano/smsusb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

-- 
2.24.0
diff mbox series

Patch

diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index ec759f43c634..3ab72d653737 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -226,10 +226,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,