]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] soc_camera: use kmemdup()
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 3 Sep 2014 17:55:19 +0000 (14:55 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 3 Sep 2014 20:58:30 +0000 (17:58 -0300)
Instead of calling kzalloc and then copying, use kmemdup(). That
avoids zeroing the data structure before copying.

Found by coccinelle.

Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/platform/soc_camera/soc_camera.c

index f4308fed54318625d6e802aac288b96bd8cecd68..ee8cdc95a9f9e7bd66af103b46a6389ea8324e0e 100644 (file)
@@ -1347,13 +1347,11 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
                return -ENODEV;
        }
 
-       ssdd = kzalloc(sizeof(*ssdd), GFP_KERNEL);
+       ssdd = kmemdup(&sdesc->subdev_desc, sizeof(*ssdd), GFP_KERNEL);
        if (!ssdd) {
                ret = -ENOMEM;
                goto ealloc;
        }
-
-       memcpy(ssdd, &sdesc->subdev_desc, sizeof(*ssdd));
        /*
         * In synchronous case we request regulators ourselves in
         * soc_camera_pdrv_probe(), make sure the subdevice driver doesn't try