Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf401e28 authored by Colin Ian King's avatar Colin Ian King Committed by Alex Deucher
Browse files

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: 1a058c33 ("drm/amdkfd: New IOCTL to allocate queue GWS")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 394e9a14
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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);