mirror of
https://github.com/torvalds/linux.git
synced 2026-06-06 21:45:45 +02:00
drm: Balance error path for GEM handle allocation
[ Upstream commit 6984128d01 ]
The current error path for failure when establishing a handle for a GEM
object is unbalance, e.g. we call object_close() without calling first
object_open(). Use the typical onion structure to only undo what has
been set up prior to the error.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
1db396648c
commit
e0df9595ca
|
|
@ -338,27 +338,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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user