diff mbox

[libdrm] tests: fix memory leak issue

Message ID 1521513968-19978-1-git-send-email-inki.dae@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Inki Dae March 20, 2018, 2:46 a.m. UTC
Fixed memory leak issue to drmModeRes object.

This object was allocated by drmModeGetResources function
but not freed when device->screens failed.

So this patch frees the drmModeRes object when device->screens failed
by calling drmModeFreeResources function.

Signed-off-by: Inki Dae <inki.dae@samsung.com>
---
 tests/kms/libkms-test-device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/tests/kms/libkms-test-device.c b/tests/kms/libkms-test-device.c
index 53c7349..8127aa7 100644
--- a/tests/kms/libkms-test-device.c
+++ b/tests/kms/libkms-test-device.c
@@ -112,7 +112,7 @@  static void kms_device_probe_crtcs(struct kms_device *device)
 
 	device->crtcs = calloc(res->count_crtcs, sizeof(crtc));
 	if (!device->crtcs)
-		return;
+		goto err_free_resources;
 
 	for (i = 0; i < res->count_crtcs; i++) {
 		crtc = kms_crtc_create(device, res->crtcs[i]);
@@ -123,6 +123,7 @@  static void kms_device_probe_crtcs(struct kms_device *device)
 		device->num_crtcs++;
 	}
 
+err_free_resources:
 	drmModeFreeResources(res);
 }