aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Carpenter2023-06-06 19:29:51 -0400
committerAlex Deucher2023-06-09 12:43:00 -0400
commit8be295046748432c53a2dee39c469f63c60b0ec3 (patch)
tree5dd23a791e0826006e0b180c4cf77f9454f08b6b
parent33e82119cfb2a957f250f92a1e4c4db2b06400db (diff)
drm/amdkfd: potential error pointer dereference in ioctl
The "target" either comes from kfd_create_process() which returns error pointers on error or kfd_lookup_process_by_pid() which returns NULL on error. So we need to check for both types of errors. Fixes: 0ab2d7532b05 ("drm/amdkfd: prepare per-process debug enable and disable") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Jonathan Kim <jonathan.kim@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_chardev.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index cce2abe12e1b..d655c5bc951f 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -2920,9 +2920,9 @@ static int kfd_ioctl_set_debug_trap(struct file *filep, struct kfd_process *p, v
target = kfd_lookup_process_by_pid(pid);
}
- if (!target) {
+ if (IS_ERR_OR_NULL(target)) {
pr_debug("Cannot find process PID %i to debug\n", args->pid);
- r = -ESRCH;
+ r = target ? PTR_ERR(target) : -ESRCH;
goto out;
}