[PATCH libdrm] tests: fix memory leak issue

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

 



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@xxxxxxxxxxx>
---
 tests/kms/libkms-test-device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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);
 }
 
-- 
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://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