Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Signed-off-by: Pan Bian <bianpan2016@163.com>
[seanpaul fixed up subject prefix]
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1480777902-7648-1-git-send-email-bianpan2016@163.com

authored by

Pan Bian and committed by
Sean Paul
16571a8a 48d98316

+1 -1
+1 -1
drivers/gpu/drm/qxl/qxl_release.c
··· 134 134 release = kmalloc(size, GFP_KERNEL); 135 135 if (!release) { 136 136 DRM_ERROR("Out of memory\n"); 137 - return 0; 137 + return -ENOMEM; 138 138 } 139 139 release->base.ops = NULL; 140 140 release->type = type;