diff options
author | Gustavo A. R. Silva <garsilva@embeddedor.com> | 2018-01-10 18:15:09 -0500 |
---|---|---|
committer | Oded Gabbay <oded.gabbay@gmail.com> | 2018-01-10 18:15:09 -0500 |
commit | 2e3dca53654ddc51bada4cee4ca32d0d266fc9dd (patch) | |
tree | e5338b7e920e57a7a03b8ed7ccfeae39dd2c928f | |
parent | a1235e10ee9a9b4d5840c6edea74479fa87c9119 (diff) |
drm/amdkfd: Fix potential NULL pointer dereferences
In case kfd_get_process_device_data returns null, there are some
null pointer dereferences in functions kfd_bind_processes_to_device
and kfd_unbind_processes_from_device.
Fix this by printing a WARN_ON for PDDs that aren't found and skip
them with continue statements.
Addresses-Coverity-ID: 1463794 ("Dereference null return value")
Addresses-Coverity-ID: 1463772 ("Dereference null return value")
Suggested-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdkfd/kfd_process.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index a22fb0710f15..4ff5f0fe6db8 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c | |||
@@ -461,7 +461,8 @@ int kfd_bind_processes_to_device(struct kfd_dev *dev) | |||
461 | hash_for_each_rcu(kfd_processes_table, temp, p, kfd_processes) { | 461 | hash_for_each_rcu(kfd_processes_table, temp, p, kfd_processes) { |
462 | mutex_lock(&p->mutex); | 462 | mutex_lock(&p->mutex); |
463 | pdd = kfd_get_process_device_data(dev, p); | 463 | pdd = kfd_get_process_device_data(dev, p); |
464 | if (pdd->bound != PDD_BOUND_SUSPENDED) { | 464 | |
465 | if (WARN_ON(!pdd) || pdd->bound != PDD_BOUND_SUSPENDED) { | ||
465 | mutex_unlock(&p->mutex); | 466 | mutex_unlock(&p->mutex); |
466 | continue; | 467 | continue; |
467 | } | 468 | } |
@@ -501,6 +502,11 @@ void kfd_unbind_processes_from_device(struct kfd_dev *dev) | |||
501 | mutex_lock(&p->mutex); | 502 | mutex_lock(&p->mutex); |
502 | pdd = kfd_get_process_device_data(dev, p); | 503 | pdd = kfd_get_process_device_data(dev, p); |
503 | 504 | ||
505 | if (WARN_ON(!pdd)) { | ||
506 | mutex_unlock(&p->mutex); | ||
507 | continue; | ||
508 | } | ||
509 | |||
504 | if (pdd->bound == PDD_BOUND) | 510 | if (pdd->bound == PDD_BOUND) |
505 | pdd->bound = PDD_BOUND_SUSPENDED; | 511 | pdd->bound = PDD_BOUND_SUSPENDED; |
506 | mutex_unlock(&p->mutex); | 512 | mutex_unlock(&p->mutex); |