[PATCH v17 11/18] drm/shmem-helper: Improve drm_gem_shmem_vmap_locked() error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Remove error unwinding from drm_gem_shmem_vmap_locked() making error
paths consistent for both dmabuf and non-dmabuf cases and improving
readability of the code. Often it's preferred to do the explicit error
unwinding, but this multi-path function is an exception.

Suggested-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx>
---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index e1fcb5154209..8a8eab4d0332 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -334,7 +334,7 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,
 			      struct iosys_map *map)
 {
 	struct drm_gem_object *obj = &shmem->base;
-	int ret = 0;
+	int ret;
 
 	if (obj->import_attach) {
 		ret = dma_buf_vmap(obj->import_attach->dmabuf, map);
@@ -357,6 +357,7 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,
 		shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
 				    VM_MAP, prot);
 		if (!shmem->vaddr) {
+			drm_gem_shmem_unpin_locked(shmem);
 			ret = -ENOMEM;
 		} else {
 			iosys_map_set_vaddr(map, shmem->vaddr);
@@ -364,16 +365,8 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,
 		}
 	}
 
-	if (ret) {
+	if (ret)
 		drm_dbg_kms(obj->dev, "Failed to vmap pages, error %d\n", ret);
-		goto err_put_pages;
-	}
-
-	return 0;
-
-err_put_pages:
-	if (!obj->import_attach)
-		drm_gem_shmem_unpin_locked(shmem);
 
 	return ret;
 }
-- 
2.41.0




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux