diff options
author | Colin Ian King <colin.king@canonical.com> | 2021-01-15 13:09:11 +0000 |
---|---|---|
committer | Melissa Wen <melissa.srw@gmail.com> | 2021-01-15 17:45:07 -0300 |
commit | 85dd1dd6e27147efe68539ef52802a7fa579f6cf (patch) | |
tree | 02f29202280922cbaf0028d3f2287dd2a91b9dad /drivers/gpu/drm/vkms | |
parent | 0d7ab835463eb41265c18184a4867a1e9f0864da (diff) | |
download | linux-85dd1dd6e27147efe68539ef52802a7fa579f6cf.tar.gz |
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 <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
Diffstat (limited to 'drivers/gpu/drm/vkms')
-rw-r--r-- | drivers/gpu/drm/vkms/vkms_drv.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 708f7f54001d..2173b82606f6 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; |