public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] drm/tegra: small leak on error in tegra_fb_alloc()
@ 2013-11-10  5:34 Dan Carpenter
       [not found] ` <20131110053406.GB13643-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2013-11-10  5:34 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Terje Bergström, David Airlie, Stephen Warren,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

If we don't have enough memory for ->planes then we leak "fb".

Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 490f771..1362d78 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)
-		return ERR_PTR(-ENOMEM);
+	if (!fb->planes) {
+		err = -ENOMEM;
+		goto free_fb;
+	}
 
 	fb->num_planes = num_planes;
 
@@ -112,12 +114,17 @@ static struct tegra_fb *tegra_fb_alloc(struct drm_device *drm,
 	if (err < 0) {
 		dev_err(drm->dev, "failed to initialize framebuffer: %d\n",
 			err);
-		kfree(fb->planes);
-		kfree(fb);
-		return ERR_PTR(err);
+		goto free_planes;
 	}
 
 	return fb;
+
+free_planes:
+	kfree(fb->planes);
+free_fb:
+	kfree(fb);
+
+	return ERR_PTR(err);
 }
 
 static struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-11  9:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-10  5:34 [patch] drm/tegra: small leak on error in tegra_fb_alloc() Dan Carpenter
     [not found] ` <20131110053406.GB13643-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2013-11-11  9:03   ` Thierry Reding
     [not found]     ` <20131111090348.GD3884-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2013-11-11  9:42       ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox