From: Stefan Agner <stefan@agner.ch>
To: airlied@linux.ie, daniel.vetter@ffwll.ch, jianwei.wang.chn@gmail.com
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
alison.wang@freescale.com
Subject: [PATCH 3/7] drm/fsl-dcu: avoid memory leak on errors
Date: Wed, 18 Nov 2015 18:42:46 -0800 [thread overview]
Message-ID: <1447900970-15936-4-git-send-email-stefan@agner.ch> (raw)
In-Reply-To: <1447900970-15936-1-git-send-email-stefan@agner.ch>
Improve error handling during CRTC initialization. Especially avoid
memory leaks in the primary plane initialization error path.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 7 ++++++-
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
index adf9212..b2f56e4 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
@@ -143,10 +143,15 @@ int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev)
int ret;
primary = fsl_dcu_drm_primary_create_plane(fsl_dev->drm);
+ if (!primary)
+ return -ENOMEM;
+
ret = drm_crtc_init_with_planes(fsl_dev->drm, crtc, primary, NULL,
&fsl_dcu_drm_crtc_funcs);
- if (ret < 0)
+ if (ret) {
+ primary->funcs->destroy(primary);
return ret;
+ }
drm_crtc_helper_add(crtc, &fsl_dcu_drm_crtc_helper_funcs);
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
index 92e606a..1cb6295 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
@@ -184,6 +184,7 @@ static const struct drm_plane_helper_funcs fsl_dcu_drm_plane_helper_funcs = {
static void fsl_dcu_drm_plane_destroy(struct drm_plane *plane)
{
drm_plane_cleanup(plane);
+ kfree(plane);
}
static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = {
--
2.6.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-11-19 2:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-19 2:42 [PATCH 0/7] drm/fsl-dcu: fixes and enhancements Stefan Agner
2015-11-19 2:42 ` [PATCH 1/7] drm/fsl-dcu: specify volatile registers Stefan Agner
2015-11-19 2:42 ` [PATCH 2/7] drm/fsl-dcu: remove regmap return value checks Stefan Agner
2015-11-19 2:42 ` Stefan Agner [this message]
2015-11-19 2:42 ` [PATCH 4/7] drm/fsl-dcu: handle initialization errors properly Stefan Agner
2015-11-19 2:42 ` [PATCH 5/7] drm/fsl-dcu: mask all interrupts on initialization Stefan Agner
2015-11-19 2:42 ` [PATCH 6/7] drm/fsl-dcu: fix alpha blending Stefan Agner
2015-11-19 2:42 ` [PATCH 7/7] drm/fsl-dcu: use mode flags for hsync/vsync pixelclk polarity Stefan Agner
2016-01-28 2:46 ` Stefan Agner
2016-02-03 14:00 ` Thierry Reding
2016-02-03 23:18 ` Stefan Agner
2016-02-04 20:31 ` Stefan Agner
2016-02-03 14:04 ` Thierry Reding
2016-02-03 23:30 ` Stefan Agner
2016-02-25 23:36 ` [PATCH 0/7] drm/fsl-dcu: fixes and enhancements Stefan Agner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447900970-15936-4-git-send-email-stefan@agner.ch \
--to=stefan@agner.ch \
--cc=airlied@linux.ie \
--cc=alison.wang@freescale.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jianwei.wang.chn@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).