Commit 3c0b4280 authored by Philip Yang's avatar Philip Yang Committed by Oded Gabbay

drm/amdkfd: Add crash protection in debugger register path

After debugger is registered, the pqm_destroy_queue fails because is_debug
is true, the queue should not be removed from process_queue_list since
the count is not reduced.

Test application calls debugger unregister without register debugger, add
null pointer check protection to avoid crash for this case
Signed-off-by: default avatarPhilip Yang <Philip.Yang@amd.com>
Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
parent a9efcc19
...@@ -526,7 +526,7 @@ static int kfd_ioctl_dbg_unregister(struct file *filep, ...@@ -526,7 +526,7 @@ static int kfd_ioctl_dbg_unregister(struct file *filep,
long status; long status;
dev = kfd_device_by_id(args->gpu_id); dev = kfd_device_by_id(args->gpu_id);
if (!dev) if (!dev || !dev->dbgmgr)
return -EINVAL; return -EINVAL;
if (dev->device_info->asic_family == CHIP_CARRIZO) { if (dev->device_info->asic_family == CHIP_CARRIZO) {
......
...@@ -311,6 +311,10 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid) ...@@ -311,6 +311,10 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
if (pqn->q) { if (pqn->q) {
dqm = pqn->q->device->dqm; dqm = pqn->q->device->dqm;
retval = dqm->ops.destroy_queue(dqm, &pdd->qpd, pqn->q); retval = dqm->ops.destroy_queue(dqm, &pdd->qpd, pqn->q);
if (retval) {
pr_debug("Destroy queue failed, returned %d\n", retval);
goto err_destroy_queue;
}
uninit_queue(pqn->q); uninit_queue(pqn->q);
} }
...@@ -322,6 +326,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid) ...@@ -322,6 +326,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
list_empty(&pdd->qpd.priv_queue_list)) list_empty(&pdd->qpd.priv_queue_list))
dqm->ops.unregister_process(dqm, &pdd->qpd); dqm->ops.unregister_process(dqm, &pdd->qpd);
err_destroy_queue:
return retval; return retval;
} }
......
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