Skip to contentSkip to conversation

media: siano: Use kmemdup instead of duplicating its function

git:media_tree/master Mauro Carvalho Chehab 1 participant 1 message Dec 7, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

This is an automatic generated email to let you know that the following patch were queued:

Subject: media: siano: Use kmemdup instead of duplicating its function
Author:  Wen Yang <[email protected]>
Date:    Thu Dec 6 07:29:10 2018 -0500

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.

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

---

drivers/media/usb/siano/smsusb.c +1 -2
index be3634407f1f..2ffded08407b 100644
@@ -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,