Skip to content

Commit 351a16c

Browse files
committed
plugin/amdgpu: validate dmabuf_fd before drmPrimeFDToHandle() call
In amdgpu_plugin_drm_restore_file(), dmabuf_fd can reach the drmPrimeFDToHandle() call as -1 if fdstore_get() fails or if boinfo->handle is -1 while boinfo->is_import is true. Passing an invalid fd to libdrm causes a hard restore failure instead of a retry. Check for -1 and set retry_needed so the restore coordinator can retry later. When retry_needed is set, some dmabufs entries are still invalid, so skip record_completed_work() and restore_bo_contents_drm() to avoid operating on incomplete state. Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
1 parent 315fbed commit 351a16c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

plugins/amdgpu/amdgpu_plugin_drm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,10 @@ int amdgpu_plugin_drm_restore_file(int fd, CriuRenderNode *rd)
538538
}
539539

540540
if (boinfo->is_import) {
541+
if (dmabuf_fd == -1) {
542+
retry_needed = true;
543+
continue;
544+
}
541545
ret = drmPrimeFDToHandle(device_fd, dmabuf_fd, &handle);
542546
if (ret) {
543547
pr_perror("Failed to get handle from dmabuf fd");
@@ -619,6 +623,9 @@ int amdgpu_plugin_drm_restore_file(int fd, CriuRenderNode *rd)
619623
goto exit;
620624
}
621625

626+
if (retry_needed)
627+
goto exit;
628+
622629
ret = record_completed_work(-1, rd->drm_render_minor);
623630
if (ret)
624631
goto exit;

0 commit comments

Comments
 (0)