drm/amdkfd: Fix an illegal memory access
authorjsg <jsg@openbsd.org>
Tue, 28 Mar 2023 04:05:41 +0000 (04:05 +0000)
committerjsg <jsg@openbsd.org>
Tue, 28 Mar 2023 04:05:41 +0000 (04:05 +0000)
From Qu Huang
d9923e7214a870b312bf61f6a89c7554d0966985 in linux-6.1.y/6.1.21
4fc8fff378b2f2039f2a666d9f8c570f4e58352c in mainline linux

sys/dev/pci/drm/amd/amdkfd/kfd_events.c

index 729d26d..2880ed9 100644 (file)
@@ -778,16 +778,13 @@ static struct kfd_event_waiter *alloc_event_waiters(uint32_t num_events)
        struct kfd_event_waiter *event_waiters;
        uint32_t i;
 
-       event_waiters = kmalloc_array(num_events,
-                                       sizeof(struct kfd_event_waiter),
-                                       GFP_KERNEL);
+       event_waiters = kcalloc(num_events, sizeof(struct kfd_event_waiter),
+                               GFP_KERNEL);
        if (!event_waiters)
                return NULL;
 
-       for (i = 0; (event_waiters) && (i < num_events) ; i++) {
+       for (i = 0; i < num_events; i++)
                init_wait(&event_waiters[i].wait);
-               event_waiters[i].activated = false;
-       }
 
        return event_waiters;
 }