Browse Source

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

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

Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sayli karnik 9 years ago
parent
commit
9edae49285
1 changed files with 1 additions and 2 deletions
  1. 1 2
      drivers/staging/greybus/es2.c

+ 1 - 2
drivers/staging/greybus/es2.c

@@ -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,