staging: greybus: es2: Use kmemdup instead of kmalloc and memcpy
authorsayli karnik <karniksayli1995@gmail.com>
Sun, 16 Oct 2016 08:49:48 +0000 (14:19 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Oct 2016 07:38:37 +0000 (09:38 +0200)
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>
drivers/staging/greybus/es2.c

index 071bb1cfd3ae1d38c510c19adbf7cdd3d9daa9a7..8eabc713a26db55721e349fad9731760b02c0670 100644 (file)
@@ -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,