From: Colin Ian King Date: Fri, 15 Jan 2021 13:09:11 +0000 (+0000) Subject: drm/vkms: Fix missing kmalloc allocation failure check X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=85dd1dd6e27147efe68539ef52802a7fa579f6cf;p=linux.git drm/vkms: Fix missing kmalloc allocation failure check Currently the kmalloc allocation for config is not being null checked and could potentially lead to a null pointer dereference. Fix this by adding the missing null check. Addresses-Coverity: ("Dereference null return value") Fixes: 2df7af93fdad ("drm/vkms: Add vkms_config type") Signed-off-by: Colin Ian King Reviewed-by: Sumera Priyadarsini Signed-off-by: Melissa Wen Link: https://patchwork.freedesktop.org/patch/msgid/20210115130911.71073-1-colin.king@canonical.com --- diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 708f7f54001d6..2173b82606f66 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -188,7 +188,11 @@ out_unregister: static int __init vkms_init(void) { - struct vkms_config *config = kmalloc(sizeof(*config), GFP_KERNEL); + struct vkms_config *config; + + config = kmalloc(sizeof(*config), GFP_KERNEL); + if (!config) + return -ENOMEM; default_config = config;