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: 2df7af93fd ("drm/vkms: Add vkms_config type")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Sumera Priyadarsini <sylphrenadin@gmail.com>
Signed-off-by: Melissa Wen <melissa.srw@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210115130911.71073-1-colin.king@canonical.com
This commit is contained in:
Colin Ian King 2021-01-15 13:09:11 +00:00 committed by Melissa Wen
parent 0d7ab83546
commit 85dd1dd6e2

View File

@ -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;