Commit ebbb7bb9 authored by QintaoShen's avatar QintaoShen Committed by Alex Deucher

drm/amdkfd: Check for potential null return of kmalloc_array()

As the kmalloc_array() may return null, the 'event_waiters[i].wait' would lead to null-pointer dereference.
Therefore, it is better to check the return value of kmalloc_array() to avoid this confusion.
Signed-off-by: default avatarQintaoShen <unSimple1993@163.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6ea239ad
...@@ -749,6 +749,8 @@ static struct kfd_event_waiter *alloc_event_waiters(uint32_t num_events) ...@@ -749,6 +749,8 @@ static struct kfd_event_waiter *alloc_event_waiters(uint32_t num_events)
event_waiters = kmalloc_array(num_events, event_waiters = kmalloc_array(num_events,
sizeof(struct kfd_event_waiter), sizeof(struct kfd_event_waiter),
GFP_KERNEL); GFP_KERNEL);
if (!event_waiters)
return NULL;
for (i = 0; (event_waiters) && (i < num_events) ; i++) { for (i = 0; (event_waiters) && (i < num_events) ; i++) {
init_wait(&event_waiters[i].wait); init_wait(&event_waiters[i].wait);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment