From 6b7c79d19157d52901398964ad115dd472cedfde Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 12 Nov 2013 13:25:26 +0300 Subject: [PATCH] drm/tegra: Fix small leak on error in tegra_fb_alloc() If we don't have enough memory for ->planes then we leak "fb". Signed-off-by: Dan Carpenter Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/fb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index bd4bf210f469..f7fca09d4921 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c @@ -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; -- 2.39.5