Skip to contentSkip to conversation

staging: greybus: es2: Use kmemdup instead of kmalloc and memcpy

PATCH In review sayli karnik 2 participants 2 messages Oct 16, 2016 – Oct 17, 2016

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

PATCH 1/1 staging: greybus: es2: Use kmemdup instead of kmalloc and memcpy

This patch replaces kmalloc and memcpy with kmemdup for duplication of memory.

---
 drivers/staging/greybus/es2.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/greybus/es2.c +1 -2
index 071bb1c..8eabc71 100644
@@ -175,10 +175,9 @@ static int output_sync(struct es2_ap_dev *es2, void *req, u16 size, u8 cmd)
 	u8 *data;
 	int retval;
 
-	data = kmalloc(size, GFP_KERNEL);
+	data = kmemdup(req, size, GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
-	memcpy(data, req, size);
 
 	retval = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 				 cmd,
Signature · 1 line
2.7.4
maintainer Acked-by on v1 1/1
#1 lore raw

[+CC: staging list ]

Quoted 4 lines · sayli karnik

This patch replaces kmalloc and memcpy with kmemdup for duplication of memory.

Quoted 10 lines
---
 drivers/staging/greybus/es2.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/greybus/es2.c +0 -0
index 071bb1c..8eabc71 100644
@@ -175,10 +175,9 @@ static int output_sync(struct es2_ap_dev *es2, void *req, u16 size, u8 cmd)
 	u8 *data;

drivers/staging/greybus/es2.c static int output_sync(struct es2_ap_dev *es2, void *req, u16 size, u8 cmd) · line 183

Quoted 10 lines
drivers/staging/greybus/es2.c +1 -2
 	int retval;
 
-	data = kmalloc(size, GFP_KERNEL);
+	data = kmemdup(req, size, GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
-	memcpy(data, req, size);
 
 	retval = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 				 cmd,

Thanks,
Johan