[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20181206122910.50908-1-wen.yang99@zte.com.cn>
Date: Thu, 6 Dec 2018 20:29:10 +0800
From: Wen Yang <wen.yang99@....com.cn>
To: Mauro Carvalho Chehab <mchehab@...nel.org>,
Tomoki Sekiyama <tomoki.sekiyama@...il.com>
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
zhong.weidong@....com.cn, Wen Yang <wen.yang99@....com.cn>
Subject: [PATCH] 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 <wen.yang99@....com.cn>
CC: Mauro Carvalho Chehab <mchehab@...nel.org>
CC: Tomoki Sekiyama <tomoki.sekiyama@...il.com>
CC: linux-media@...r.kernel.org
CC: linux-kernel@...r.kernel.org
---
drivers/media/usb/siano/smsusb.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index be3634407f1f..2ffded08407b 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,
--
2.19.1
Powered by blists - more mailing lists