From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: David Airlie <airlied@linux.ie>, Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH] drm/mgag200: fix memory leak
Date: Mon, 7 Sep 2015 17:28:30 +0530 [thread overview]
Message-ID: <1441627110-13783-1-git-send-email-sudipm.mukherjee@gmail.com> (raw)
If drm_fb_helper_alloc_fbi() fails then we were directly returning
without freeing sysram. Also if drm_fb_helper_alloc_fbi() succeeds but
mgag200_framebuffer_init() fails then we were not releasing sysram and
we were not releasing fbi helper also.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
drivers/gpu/drm/mgag200/mgag200_fb.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 87de15e..5fe476a 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -189,14 +189,16 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
return -ENOMEM;
info = drm_fb_helper_alloc_fbi(helper);
- if (IS_ERR(info))
- return PTR_ERR(info);
+ if (IS_ERR(info)) {
+ ret = PTR_ERR(info);
+ goto err_alloc_fbi;
+ }
info->par = mfbdev;
ret = mgag200_framebuffer_init(dev, &mfbdev->mfb, &mode_cmd, gobj);
if (ret)
- return ret;
+ goto err_framebuffer_init;
mfbdev->sysram = sysram;
mfbdev->size = size;
@@ -226,6 +228,13 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
DRM_DEBUG_KMS("allocated %dx%d\n",
fb->width, fb->height);
return 0;
+
+err_framebuffer_init:
+ drm_fb_helper_release_fbi(helper);
+
+err_alloc_fbi:
+ vfree(sysram);
+ return ret;
}
static int mga_fbdev_destroy(struct drm_device *dev,
--
1.9.1
next reply other threads:[~2015-09-07 11:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-07 11:58 Sudip Mukherjee [this message]
2015-09-13 9:36 ` Ingo Molnar
2015-09-14 8:44 ` Sudip Mukherjee
2015-09-14 9:06 ` Ingo Molnar
2015-09-14 10:04 ` Dave Airlie
2015-09-14 10:05 ` Dave Airlie
2015-09-14 10:29 ` Sudip Mukherjee
2015-09-14 15:23 ` Archit Taneja
2015-09-16 9:46 ` [PATCH] drm/mgag200: Fix calling drm_fb_helper_fini() twice Ingo Molnar
2015-09-17 8:34 ` Ingo Molnar
2015-09-17 10:54 ` Archit Taneja
2015-09-17 11:17 ` Sudip Mukherjee
2015-10-03 10:55 ` Ingo Molnar
2015-09-24 15:53 ` [PATCH] drm/mgag200: fix memory leak Sudip Mukherjee
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=1441627110-13783-1-git-send-email-sudipm.mukherjee@gmail.com \
--to=sudipm.mukherjee@gmail.com \
--cc=airlied@linux.ie \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--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
all inboxes | Powered by JetHome®