drm/tegra: Fix small leak on error in tegra_fb_alloc()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 12 Nov 2013 10:25:26 +0000 (13:25 +0300)
committerThierry Reding <treding@nvidia.com>
Fri, 20 Dec 2013 14:56:06 +0000 (15:56 +0100)
If we don't have enough memory for ->planes then we leak "fb".

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/drm/tegra/fb.c

index bd4bf21..f7fca09 100644 (file)
@@ -100,8 +100,10 @@ static struct tegra_fb *tegra_fb_alloc(struct drm_device *drm,
                return ERR_PTR(-ENOMEM);
 
        fb->planes = kzalloc(num_planes * sizeof(*planes), GFP_KERNEL);
-       if (!fb->planes)
+       if (!fb->planes) {
+               kfree(fb);
                return ERR_PTR(-ENOMEM);
+       }
 
        fb->num_planes = num_planes;