summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorPallavi Mishra <pallavi.mishra@intel.com>2023-08-31 02:25:58 +0300
committerRodrigo Vivi <rodrigo.vivi@intel.com>2023-12-21 19:40:28 +0300
commit9c0d779fc67bd1810f74c22e219f4af24a4e1e29 (patch)
tree93b9b41149a80c3ee607109a6d464dfe7e717868 /drivers
parent14ec22408d2fa1d8671b619474381344b2bc859a (diff)
downloadlinux-9c0d779fc67bd1810f74c22e219f4af24a4e1e29.tar.xz
drm/xe: Prevent return with locked vm
Reorder vm_id check after the one for VISIBLE_VRAM. This should prevent returning with locked vm in error scenario. Signed-off-by: Pallavi Mishra <pallavi.mishra@intel.com> Cc: Matthew Auld <matthew.auld@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/xe/xe_bo.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 80c5d1a7d41a..3cfd3f37c81e 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -1795,17 +1795,6 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
if (XE_IOCTL_DBG(xe, args->size & ~PAGE_MASK))
return -EINVAL;
- if (args->vm_id) {
- vm = xe_vm_lookup(xef, args->vm_id);
- if (XE_IOCTL_DBG(xe, !vm))
- return -ENOENT;
- err = xe_vm_lock(vm, &ww, 0, true);
- if (err) {
- xe_vm_put(vm);
- return err;
- }
- }
-
if (args->flags & XE_GEM_CREATE_FLAG_DEFER_BACKING)
bo_flags |= XE_BO_DEFER_BACKING;
@@ -1821,6 +1810,17 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
bo_flags |= XE_BO_NEEDS_CPU_ACCESS;
}
+ if (args->vm_id) {
+ vm = xe_vm_lookup(xef, args->vm_id);
+ if (XE_IOCTL_DBG(xe, !vm))
+ return -ENOENT;
+ err = xe_vm_lock(vm, &ww, 0, true);
+ if (err) {
+ xe_vm_put(vm);
+ return err;
+ }
+ }
+
bo = xe_bo_create(xe, NULL, vm, args->size, ttm_bo_type_device,
bo_flags);
if (IS_ERR(bo)) {