diff options
author | ChunyouTang <tangchunyou@163.com> | 2022-11-19 14:41:31 +0800 |
---|---|---|
committer | Thomas Zimmermann <tzimmermann@suse.de> | 2022-11-21 16:55:52 +0100 |
commit | 7df34a619f59439f38e56d389df02ee7e9e8cc97 (patch) | |
tree | de93d1ded17ca0c3602297c106d04a24682b4988 /drivers/gpu/drm/drm_gem.c | |
parent | e3ddd2d25533d1cc6f9fea421e4a5f16b60b3434 (diff) | |
download | lwn-7df34a619f59439f38e56d389df02ee7e9e8cc97.tar.gz lwn-7df34a619f59439f38e56d389df02ee7e9e8cc97.zip |
drm/gem-shmem: When drm_gem_object_init failed, should release object
when goto err_free, the object had init, so it should be release when fail.
Signed-off-by: ChunyouTang <tangchunyou@163.com>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20221119064131.364-1-tangchunyou@163.com
Diffstat (limited to 'drivers/gpu/drm/drm_gem.c')
-rw-r--r-- | drivers/gpu/drm/drm_gem.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index b8db675e7fb5..59a0bb5ebd85 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -170,6 +170,20 @@ void drm_gem_private_object_init(struct drm_device *dev, EXPORT_SYMBOL(drm_gem_private_object_init); /** + * drm_gem_private_object_fini - Finalize a failed drm_gem_object + * @obj: drm_gem_object + * + * Uninitialize an already allocated GEM object when it initialized failed + */ +void drm_gem_private_object_fini(struct drm_gem_object *obj) +{ + WARN_ON(obj->dma_buf); + + dma_resv_fini(&obj->_resv); +} +EXPORT_SYMBOL(drm_gem_private_object_fini); + +/** * drm_gem_object_handle_free - release resources bound to userspace handles * @obj: GEM object to clean up. * @@ -930,12 +944,11 @@ drm_gem_release(struct drm_device *dev, struct drm_file *file_private) void drm_gem_object_release(struct drm_gem_object *obj) { - WARN_ON(obj->dma_buf); - if (obj->filp) fput(obj->filp); - dma_resv_fini(&obj->_resv); + drm_gem_private_object_fini(obj); + drm_gem_free_mmap_offset(obj); drm_gem_lru_remove(obj); } |