diff mbox

[v2] drm/tegra: fix small leak on error in tegra_fb_alloc()

Message ID 20131112102526.GA10651@elgon.mountain
State Not Applicable, archived
Headers show

Commit Message

Dan Carpenter Nov. 12, 2013, 10:25 a.m. UTC
If we don't have enough memory for ->planes then we leak "fb".

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: tiny style changes

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Thierry Reding Dec. 3, 2013, 10:10 a.m. UTC | #1
On Tue, Nov 12, 2013 at 01:25:26PM +0300, Dan Carpenter wrote:
> If we don't have enough memory for ->planes then we leak "fb".
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: tiny style changes

Applied, thanks.

Thierry
diff mbox

Patch

diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 490f771..f9d2de6 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -98,8 +98,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;