When some other buffer is immediately copied into allocated region.
Replace calls to kmalloc followed by a memcpy with a direct
call to kmemdup.

Signed-off-by: Shyam Saini <mayhs11sa...@gmail.com>
---
 drivers/media/usb/cpia2/cpia2_usb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/usb/cpia2/cpia2_usb.c 
b/drivers/media/usb/cpia2/cpia2_usb.c
index 37f9b30..ce36331 100644
--- a/drivers/media/usb/cpia2/cpia2_usb.c
+++ b/drivers/media/usb/cpia2/cpia2_usb.c
@@ -551,12 +551,10 @@ static int write_packet(struct usb_device *udev,
        if (!registers || size <= 0)
                return -EINVAL;
 
-       buf = kmalloc(size, GFP_KERNEL);
+       buf = kmemdup(registers, size, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
 
-       memcpy(buf, registers, size);
-
        ret = usb_control_msg(udev,
                               usb_sndctrlpipe(udev, 0),
                               request,
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to