[PATCH libdrm] tests/libkms-test-plane: fix possbile memory leak

Seung-Woo Kim sw0312.kim at samsung.com
Thu Apr 25 09:50:00 UTC 2019


The pointer p aquired with drmModeGetPlane() is not free in error
path. Fix possible memory leak by calling drmModeFreePlane() in
the error path.

Signed-off-by: Seung-Woo Kim <sw0312.kim at samsung.com>
---
 tests/kms/libkms-test-plane.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/tests/kms/libkms-test-plane.c b/tests/kms/libkms-test-plane.c
index 6c40a3c..4cb2737 100644
--- a/tests/kms/libkms-test-plane.c
+++ b/tests/kms/libkms-test-plane.c
@@ -55,8 +55,10 @@ static int kms_plane_probe(struct kms_plane *plane)
 	}
 
 	plane->formats = calloc(p->count_formats, sizeof(uint32_t));
-	if (!plane->formats)
+	if (!plane->formats) {
+		drmModeFreePlane(p);
 		return -ENOMEM;
+	}
 
 	for (i = 0; i < p->count_formats; i++)
 		plane->formats[i] = p->formats[i];
-- 
1.7.4.1



More information about the dri-devel mailing list