drm/amdkfd: Check for potential null return of kmalloc_array()
authorjsg <jsg@openbsd.org>
Thu, 21 Apr 2022 09:47:25 +0000 (09:47 +0000)
committerjsg <jsg@openbsd.org>
Thu, 21 Apr 2022 09:47:25 +0000 (09:47 +0000)
From QintaoShen
f2658d5966bcee8c3eb487875f459756d4f7cdfc in linux 5.15.y/5.15.35
ebbb7bb9e80305820dc2328a371c1b35679f2667 in mainline linux

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

index 3eea4ed..b8bdd79 100644 (file)
@@ -531,6 +531,8 @@ static struct kfd_event_waiter *alloc_event_waiters(uint32_t num_events)
        event_waiters = kmalloc_array(num_events,
                                        sizeof(struct kfd_event_waiter),
                                        GFP_KERNEL);
+       if (!event_waiters)
+               return NULL;
 
        for (i = 0; (event_waiters) && (i < num_events) ; i++) {
                init_wait(&event_waiters[i].wait);