]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amdkfd: fix a potential NULL pointer dereference (v2)
authorAllen Pais <allen.pais@oracle.com>
Wed, 18 Sep 2019 16:30:31 +0000 (22:00 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 3 Oct 2019 14:11:00 +0000 (09:11 -0500)
alloc_workqueue is not checked for errors and as a result,
a potential NULL dereference could occur.

v2 (Felix Kuehling):
* Fix compile error (kfifo_free instead of fifo_free)
* Return proper error code

Signed-off-by: Allen Pais <allen.pais@oracle.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c

index c56ac47cd3189779333acc9e8da89a8f9ad7c5be..bc47f6a44456440a0d85ad028fe75d5f83b3e8be 100644 (file)
@@ -62,6 +62,11 @@ int kfd_interrupt_init(struct kfd_dev *kfd)
        }
 
        kfd->ih_wq = alloc_workqueue("KFD IH", WQ_HIGHPRI, 1);
+       if (unlikely(!kfd->ih_wq)) {
+               kfifo_free(&kfd->ih_fifo);
+               dev_err(kfd_chardev(), "Failed to allocate KFD IH workqueue\n");
+               return -ENOMEM;
+       }
        spin_lock_init(&kfd->interrupt_lock);
 
        INIT_WORK(&kfd->interrupt_work, interrupt_wq);