diff options
author | Colin Ian King <colin.king@canonical.com> | 2019-05-29 18:07:34 +0300 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2019-05-30 00:50:09 +0300 |
commit | cf401e2856b27b2deeada498eab864e2a50cf219 (patch) | |
tree | b53ebd525a0c1e79772a47fbeb419035d680bbde | |
parent | 394e9a14c63d58e0f45323629a3f9ce1e5bf0215 (diff) | |
download | linux-cf401e2856b27b2deeada498eab864e2a50cf219.tar.xz |
drm/amdkfd: fix null pointer dereference on dev
The pointer dev is set to null yet it is being dereferenced when
checking dev->dqm->sched_policy. Fix this by performing the check
on dev->dqm->sched_policy after dev has been assigned and null
checked. Also remove the redundant null assignment to dev.
Addresses-Coverity: ("Explicit null dereference")
Fixes: 1a058c337676 ("drm/amdkfd: New IOCTL to allocate queue GWS")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index aab2aa6c1dee..ea82828fdc76 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1572,10 +1572,9 @@ static int kfd_ioctl_alloc_queue_gws(struct file *filep, { int retval; struct kfd_ioctl_alloc_queue_gws_args *args = data; - struct kfd_dev *dev = NULL; + struct kfd_dev *dev; - if (!hws_gws_support || - dev->dqm->sched_policy == KFD_SCHED_POLICY_NO_HWS) + if (!hws_gws_support) return -EINVAL; dev = kfd_device_by_id(args->gpu_id); @@ -1583,6 +1582,8 @@ static int kfd_ioctl_alloc_queue_gws(struct file *filep, pr_debug("Could not find gpu id 0x%x\n", args->gpu_id); return -EINVAL; } + if (dev->dqm->sched_policy == KFD_SCHED_POLICY_NO_HWS) + return -EINVAL; mutex_lock(&p->mutex); retval = pqm_set_gws(&p->pqm, args->queue_id, args->num_gws ? dev->gws : NULL); |