[PATCH 1/5] libkms/intel.c: Fix a memory leak and a dead assignment as well as cleanup code a bit.

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

 



---
 libkms/intel.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/libkms/intel.c b/libkms/intel.c
index 8b8249b..b8ac343 100644
--- a/libkms/intel.c
+++ b/libkms/intel.c
@@ -93,14 +93,18 @@ intel_bo_create(struct kms_driver *kms,
 	if (!bo)
 		return -ENOMEM;
 
-	if (type == KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8) {
+	switch (type) {
+	case KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8:
 		pitch = 64 * 4;
 		size = 64 * 64 * 4;
-	} else if (type == KMS_BO_TYPE_SCANOUT_X8R8G8B8) {
+		break;
+	case KMS_BO_TYPE_SCANOUT_X8R8G8B8:
 		pitch = width * 4;
 		pitch = (pitch + 512 - 1) & ~(512 - 1);
 		size = pitch * ((height + 4 - 1) & ~(4 - 1));
-	} else {
+		break;
+	default:
+		free(bo);
 		return -EINVAL;
 	}
 
@@ -108,8 +112,10 @@ intel_bo_create(struct kms_driver *kms,
 	arg.size = size;
 
 	ret = drmCommandWriteRead(kms->fd, DRM_I915_GEM_CREATE, &arg, sizeof(arg));
-	if (ret)
-		goto err_free;
+	if (ret) {
+		free(bo);
+		return ret;
+	}
 
 	bo->base.kms = kms;
 	bo->base.handle = arg.handle;
@@ -124,21 +130,18 @@ intel_bo_create(struct kms_driver *kms,
 		tile.handle = bo->base.handle;
 		tile.tiling_mode = I915_TILING_X;
 		tile.stride = bo->base.pitch;
-
-		ret = drmCommandWriteRead(kms->fd, DRM_I915_GEM_SET_TILING, &tile, sizeof(tile));
 #if 0
+		ret = drmCommandWriteRead(kms->fd, DRM_I915_GEM_SET_TILING, &tile, sizeof(tile));
 		if (ret) {
 			kms_bo_destroy(out);
 			return ret;
 		}
+#else
+		drmCommandWriteRead(kms->fd, DRM_I915_GEM_SET_TILING, &tile, sizeof(tile));
 #endif
 	}
 
 	return 0;
-
-err_free:
-	free(bo);
-	return ret;
 }
 
 static int
-- 
1.7.7

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[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