All other callers of kfd_process_device_data_by_id deal with a possible NULL return value except kfd_profiler_pmc.
Check it after the mutex unlock and return -EINVAL as others place do. Reported-by: Sashiko-bot <[email protected]> Closes: https://sashiko.dev/#/patchset/[email protected]?part=4 Signed-off-by: Pierre-Eric Pelloux-Prayer <[email protected]> --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 6c710e4a5220..ad086240a6dd 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -3463,8 +3463,10 @@ static inline int kfd_profiler_pmc(struct kfd_process *p, /* Enable/disable perfcount if requested */ mutex_lock(&p->mutex); pdd = kfd_process_device_data_by_id(p, args->gpu_id); - dqm = pdd->dev->dqm; mutex_unlock(&p->mutex); + if (!pdd) + return -EINVAL; + dqm = pdd->dev->dqm; dqm->ops.set_perfcount(dqm, args->perfcount_enable); return status; -- 2.43.0
