From: Bernard Zhao <bernard@vivo.com>
To: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org,
linux-kernel@vger.kernel.org
Cc: Bernard Zhao <bernard@vivo.com>
Subject: [PATCH] drm/xen: fix potential memleak in error branch
Date: Sun, 14 Nov 2021 19:45:03 -0800 [thread overview]
Message-ID: <20211115034504.4993-1-bernard@vivo.com> (raw)
In function xen_drm_front_gem_import_sg_table, if in error branch,
there maybe potential memleak if not call gem_free_pages_array.
Signed-off-by: Bernard Zhao <bernard@vivo.com>
---
drivers/gpu/drm/xen/xen_drm_front_gem.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c
index b293c67230ef..732c3eec0666 100644
--- a/drivers/gpu/drm/xen/xen_drm_front_gem.c
+++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c
@@ -222,15 +222,19 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev,
ret = drm_prime_sg_to_page_array(sgt, xen_obj->pages,
xen_obj->num_pages);
- if (ret < 0)
+ if (ret < 0) {
+ gem_free_pages_array(xen_obj);
return ERR_PTR(ret);
+ }
ret = xen_drm_front_dbuf_create(drm_info->front_info,
xen_drm_front_dbuf_to_cookie(&xen_obj->base),
0, 0, 0, size, sgt->sgl->offset,
xen_obj->pages);
- if (ret < 0)
+ if (ret < 0) {
+ gem_free_pages_array(xen_obj);
return ERR_PTR(ret);
+ }
DRM_DEBUG("Imported buffer of size %zu with nents %u\n",
size, sgt->orig_nents);
--
2.33.1
next reply other threads:[~2021-11-15 3:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 3:45 Bernard Zhao [this message]
2021-11-15 14:04 ` Oleksandr Andrushchenko
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=20211115034504.4993-1-bernard@vivo.com \
--to=bernard@vivo.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksandr_andrushchenko@epam.com \
--cc=xen-devel@lists.xenproject.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®