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 bd4bf210f469bd07c4e0caf39c147efd6e4dd067..f7fca09d49211c5afebdc797590c001a88e72d6d 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;