Skip to content

Commit

Permalink
drm/amdkfd: Check for potential null return of kmalloc_array()
Browse files Browse the repository at this point in the history
[ Upstream commit ebbb7bb ]

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: QintaoShen <unSimple1993@163.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
QintaoShen authored and Greg Kroah-Hartman committed Apr 20, 2022
1 parent e5afacc commit 1d7a5aa
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/amd/amdkfd/kfd_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1d7a5aa

Please sign in to comment.