[PATCH libdrm] tests: fix memory leak issue
Inki Dae
inki.dae at samsung.com
Tue Mar 20 02:46:08 UTC 2018
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 at samsung.com>
---
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
More information about the dri-devel
mailing list