Skip to contentSkip to conversation

gpu: drm: qxl: fix use of uninitialized variable

PATCH Applied Pan Bian 2 participants 2 messages Dec 3, 2016 – Dec 5, 2016

Subsystems (3)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 gpu: drm: qxl: fix use of uninitialized variable

In function qxl_release_alloc(), when kmalloc() returns a NULL pointer, it returns value 0 and parameter *ret is uninitialized. 0 means no error to the callers of qxl_release_alloc(). The callers keep going and will try to reference the uninitialized variable. This patch fixes the bug, returning "-ENOMEM" when kmalloc() fails.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188911

---
 drivers/gpu/drm/qxl/qxl_release.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_release.c +1 -1
index cd83f05..e6daa70 100644
@@ -133,7 +133,7 @@ static long qxl_fence_wait(struct fence *fence, bool intr, signed long timeout)
 	release = kmalloc(size, GFP_KERNEL);
 	if (!release) {
 		DRM_ERROR("Out of memory\n");
-		return 0;
+		return -ENOMEM;
 	}
 	release->base.ops = NULL;
 	release->type = type;
Signature · 1 line
1.9.1
Applied
#1 lore raw
Quoted 9 lines · Pan Bian

In function qxl_release_alloc(), when kmalloc() returns a NULL pointer, it returns value 0 and parameter *ret is uninitialized. 0 means no error to the callers of qxl_release_alloc(). The callers keep going and will try to reference the uninitialized variable. This patch fixes the bug, returning "-ENOMEM" when kmalloc() fails.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188911

Applied to drm-misc, with subject prefix tweak s_gpu: drm: qxl_drm/qxl_

Thanks!

Sean

Quoted 18 lines
---
 drivers/gpu/drm/qxl/qxl_release.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_release.c +1 -2
index cd83f05..e6daa70 100644
@@ -133,7 +133,7 @@ static long qxl_fence_wait(struct fence *fence, bool intr, signed long timeout)
        release = kmalloc(size, GFP_KERNEL);
        if (!release) {
                DRM_ERROR("Out of memory\n");
-               return 0;
+               return -ENOMEM;
        }
        release->base.ops = NULL;
        release->type = type;
--
Quoted 3 lines

1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel