]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
amdkfd: find kfd_process by filep->private_data in kfd_mmap
authorZhu Lingshan <lingshan.zhu@amd.com>
Mon, 4 Aug 2025 07:33:51 +0000 (15:33 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 8 Dec 2025 18:56:42 +0000 (13:56 -0500)
This commit finds the proper kfd_process by
filep->private_data in kfd_mmap,
because the function kfd_get_process()
can not locate a specific kfd process among
multiple contexts.

Signed-off-by: Zhu Lingshan <lingshan.zhu@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

index ff1a6a90346331feba35637ba20897149a0eb91b..14bee49f0bf95111a44ba785184e19583970deb0 100644 (file)
@@ -3414,16 +3414,19 @@ static int kfd_mmio_mmap(struct kfd_node *dev, struct kfd_process *process,
 }
 
 
-static int kfd_mmap(struct file *filp, struct vm_area_struct *vma)
+static int kfd_mmap(struct file *filep, struct vm_area_struct *vma)
 {
        struct kfd_process *process;
        struct kfd_node *dev = NULL;
        unsigned long mmap_offset;
        unsigned int gpu_id;
 
-       process = kfd_get_process(current);
-       if (IS_ERR(process))
-               return PTR_ERR(process);
+       process = filep->private_data;
+       if (!process)
+               return -ESRCH;
+
+       if (process->lead_thread != current->group_leader)
+               return -EBADF;
 
        mmap_offset = vma->vm_pgoff << PAGE_SHIFT;
        gpu_id = KFD_MMAP_GET_GPU_ID(mmap_offset);