diff options
Diffstat (limited to 'sys/dev/pci/drm/drm_gem.c')
-rw-r--r-- | sys/dev/pci/drm/drm_gem.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/sys/dev/pci/drm/drm_gem.c b/sys/dev/pci/drm/drm_gem.c index 91d6d84e09c..dadb5366099 100644 --- a/sys/dev/pci/drm/drm_gem.c +++ b/sys/dev/pci/drm/drm_gem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_gem.c,v 1.3 2016/04/05 20:50:44 kettenis Exp $ */ +/* $OpenBSD: drm_gem.c,v 1.4 2017/07/01 16:00:25 kettenis Exp $ */ /* * Copyright © 2008 Intel Corporation * @@ -288,6 +288,8 @@ int drm_gem_object_init(struct drm_device *dev, atomic_inc(&dev->obj_count); atomic_add(obj->size, &dev->obj_memory); + obj->filp = (void *)obj->uao; + return 0; } @@ -469,27 +471,32 @@ drm_gem_handle_create_tail(struct drm_file *file_priv, spin_unlock(&file_priv->table_lock); idr_preload_end(); mutex_unlock(&dev->object_name_lock); - if (ret < 0) { - drm_gem_object_handle_unreference_unlocked(obj); - return ret; - } + if (ret < 0) + goto err_unref; + *handlep = ret; ret = drm_vma_node_allow(&obj->vma_node, file_priv->filp); - if (ret) { - drm_gem_handle_delete(file_priv, *handlep); - return ret; - } + if (ret) + goto err_remove; if (dev->driver->gem_open_object) { ret = dev->driver->gem_open_object(obj, file_priv); - if (ret) { - drm_gem_handle_delete(file_priv, *handlep); - return ret; - } + if (ret) + goto err_revoke; } return 0; + +err_revoke: + drm_vma_node_revoke(&obj->vma_node, file_priv->filp); +err_remove: + spin_lock(&file_priv->table_lock); + idr_remove(&file_priv->object_idr, *handlep); + spin_unlock(&file_priv->table_lock); +err_unref: + drm_gem_object_handle_unreference_unlocked(obj); + return ret; } /** |