From: Takashi Iwai <tiwai@suse.de>
To: dri-devel@lists.freedesktop.org
Cc: Egbert Eich <eich@suse.de>, Dave Airlie <airlied@redhat.com>,
Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 3/5] drm/ast: Fix memleak in error path in ast_bo_create()
Date: Tue, 18 Jul 2017 16:47:38 +0200 [thread overview]
Message-ID: <20170718144740.9048-4-tiwai@suse.de> (raw)
In-Reply-To: <20170718144740.9048-1-tiwai@suse.de>
From: Egbert Eich <eich@suse.de>
The allocated struct ast_bo was not freed in all error paths.
This patch consolidates error handling and fixes this.
Signed-off-by: Egbert Eich <eich@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
drivers/gpu/drm/ast/ast_ttm.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index 0b4c574defe7..696a15dc2f3f 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -323,10 +323,8 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
return -ENOMEM;
ret = drm_gem_object_init(dev, &astbo->gem, size);
- if (ret) {
- kfree(astbo);
- return ret;
- }
+ if (ret)
+ goto error;
astbo->bo.bdev = &ast->ttm.bdev;
@@ -340,10 +338,13 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
align >> PAGE_SHIFT, false, NULL, acc_size,
NULL, NULL, ast_bo_ttm_destroy);
if (ret)
- return ret;
+ goto error;
*pastbo = astbo;
return 0;
+error:
+ kfree(astbo);
+ return ret;
}
static inline u64 ast_bo_gpu_offset(struct ast_bo *bo)
--
2.13.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-07-18 14:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-18 14:47 [PATCH 0/5] ast fix patches Takashi Iwai
2017-07-18 14:47 ` [PATCH 1/5] drm/ast: Simplify function ast_bo_unpin() Takashi Iwai
2017-07-18 14:47 ` [PATCH 2/5] drm/ast: Free container instead of member in ast_user_framebuffer_destroy() Takashi Iwai
2017-07-18 14:47 ` Takashi Iwai [this message]
2017-07-18 14:47 ` [PATCH 4/5] drm/ast: Add an crtc_disable callback to the crtc helper funcs Takashi Iwai
2017-07-18 14:47 ` [PATCH 5/5] drm/ast: Actually load DP501 firmware when required Takashi Iwai
2017-08-02 2:21 ` [PATCH 0/5] ast fix patches Dave Airlie
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=20170718144740.9048-4-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=airlied@redhat.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=eich@suse.de \
/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).