media: media/usb: Use kmemdup rather than duplicating its implementation
[sfrench/cifs-2.6.git] / drivers / media / usb / em28xx / em28xx-cards.c
index 1283c7ca9ad51a4fa399d81a107aeea14703b209..6e33782c3ca659d3d08acfe06bfa9a54b5d415a4 100644 (file)
@@ -3566,13 +3566,12 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
 static int em28xx_duplicate_dev(struct em28xx *dev)
 {
        int nr;
-       struct em28xx *sec_dev = kzalloc(sizeof(*sec_dev), GFP_KERNEL);
+       struct em28xx *sec_dev = kmemdup(dev, sizeof(*sec_dev), GFP_KERNEL);
 
        if (!sec_dev) {
                dev->dev_next = NULL;
                return -ENOMEM;
        }
-       memcpy(sec_dev, dev, sizeof(*sec_dev));
        /* Check to see next free device and mark as used */
        do {
                nr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);