]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdkfd: Check for pdd drm file first in CRIU restore path
authorDavid Francis <David.Francis@amd.com>
Thu, 14 May 2026 14:31:20 +0000 (10:31 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 27 May 2026 14:40:39 +0000 (10:40 -0400)
CRIU restore ioctls are meant to be called by CRIU with no
existing drm file. There's an error path
for if the drm file unexpectedly exists. It was positioned so
it was missing a fput(drm_file).

Do that check earlier, as soon as we have the pdd.

Signed-off-by: David Francis <David.Francis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

index 81bcb16eb6ddcd7e67c6389e841c3a53b6530c86..a2b100d1442581c76486ffead7557506e40a8ac1 100644 (file)
@@ -2399,6 +2399,11 @@ static int criu_restore_devices(struct kfd_process *p,
                        ret = -EINVAL;
                        goto exit;
                }
+
+               if (pdd->drm_file) {
+                       ret = -EINVAL;
+                       goto exit;
+               }
                pdd->user_gpu_id = device_buckets[i].user_gpu_id;
 
                drm_file = fget(device_buckets[i].drm_fd);
@@ -2409,11 +2414,6 @@ static int criu_restore_devices(struct kfd_process *p,
                        goto exit;
                }
 
-               if (pdd->drm_file) {
-                       ret = -EINVAL;
-                       goto exit;
-               }
-
                /* create the vm using render nodes for kfd pdd */
                if (kfd_process_device_init_vm(pdd, drm_file)) {
                        pr_err("could not init vm for given pdd\n");