drm/sun4i: Fix kcalloc element size in sun4i_layers_init
authorChen-Yu Tsai <wens@csie.org>
Fri, 17 Feb 2017 03:13:27 +0000 (11:13 +0800)
committerMaxime Ripard <maxime.ripard@free-electrons.com>
Tue, 7 Mar 2017 21:15:15 +0000 (22:15 +0100)
In sun4i_layers_init we are allocating an array of pointers to struct
sun4i_layer:

layers = devm_kcalloc(drm->dev, ARRAY_SIZE(sun4i_backend_planes),
                      sizeof(**layers), GFP_KERNEL);

The element size should be the size of an individual element of the
array. Change it to sizeof(*layers) to avoid wasting a lot of memory.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
drivers/gpu/drm/sun4i/sun4i_layer.c

index 5d53c977bca5d0cce752e389f7dc9b38ce195155..62552a356d6688d03a5701da49bceb52105c4efa 100644 (file)
@@ -140,7 +140,7 @@ struct sun4i_layer **sun4i_layers_init(struct drm_device *drm)
        int i;
 
        layers = devm_kcalloc(drm->dev, ARRAY_SIZE(sun4i_backend_planes),
-                             sizeof(**layers), GFP_KERNEL);
+                             sizeof(*layers), GFP_KERNEL);
        if (!layers)
                return ERR_PTR(-ENOMEM);