staging: bcm2835-camera: prefer allocating memory using sizeof(*ptr) instead of sizeo...
authorAishwarya Pant <aishpant@gmail.com>
Wed, 1 Mar 2017 18:24:01 +0000 (23:54 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Mar 2017 12:57:17 +0000 (13:57 +0100)
Using sizeof(*ptr) instead of sizeof(struct type name) is more robust to
errors.

Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c

index 84650d9a8d06b83a11e92ad27741d95d939b1da9..c9a68d4ebd158f75eeaf54701ef99fc26c6a85f3 100644 (file)
@@ -1908,7 +1908,7 @@ static int __init bm2835_mmal_init(void)
                num_cameras = MAX_BCM2835_CAMERAS;
 
        for (camera = 0; camera < num_cameras; camera++) {
-               dev = kzalloc(sizeof(struct bm2835_mmal_dev), GFP_KERNEL);
+               dev = kzalloc(sizeof(*dev), GFP_KERNEL);
                if (!dev) {
                        ret = -ENOMEM;
                        goto cleanup_gdev;