[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1430025269-26243-2-git-send-email-green@linuxhacker.ru>
Date: Sun, 26 Apr 2015 01:14:28 -0400
From: green@...uxhacker.ru
To: David Airlie <airlied@...ux.ie>, dri-devel@...ts.freedesktop.org
Cc: linux-kernel@...r.kernel.org (open list),
kernel-janitors@...r.kernel.org, Oleg Drokin <green@...uxhacker.ru>
Subject: [PATCH 1/2] drm/qlx: Fix a memory leak on error path
From: Oleg Drokin <green@...uxhacker.ru>
shadow allocation could be leaked if framebuffer allocation failed,
so need to free it.
Also added handling for shadow allocation failure itself instead
of causing a crash.
Found with smatch.
Signed-off-by: Oleg Drokin <green@...uxhacker.ru>
---
drivers/gpu/drm/qxl/qxl_fb.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index f778c0e..2a88eae 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -526,8 +526,10 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
mode_cmd.height, mode_cmd.pitches[0]);
shadow = vmalloc(mode_cmd.pitches[0] * mode_cmd.height);
- /* TODO: what's the usual response to memory allocation errors? */
- BUG_ON(!shadow);
+ if (!shadow) {
+ ret = -ENOMEM;
+ goto out_unref;
+ }
QXL_INFO(qdev,
"surface0 at gpu offset %lld, mmap_offset %lld (virt %p, shadow %p)\n",
qxl_bo_gpu_offset(qbo),
@@ -538,6 +540,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
info = framebuffer_alloc(0, device);
if (info == NULL) {
+ vfree(shadow);
ret = -ENOMEM;
goto out_unref;
}
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists