[RESEND PATCH libdrm] tests: fix memory leak issue
Inki Dae
inki.dae at samsung.com
Tue Mar 20 03:47:33 UTC 2018
Fixed memory leak issue to drmModeRes and drmModePlaneRes objects.
These objects were allocated by drmModeGetResources and
drmModeGetPlaneResources functions but not freed properly.
So this patch frees them by calling drmModeFreeResources
drmModeFreePlaneResources functions at failure case.
Signed-off-by: Inki Dae <inki.dae at samsung.com>
---
tests/kms/libkms-test-device.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/tests/kms/libkms-test-device.c b/tests/kms/libkms-test-device.c
index 53c7349..042ae05 100644
--- a/tests/kms/libkms-test-device.c
+++ b/tests/kms/libkms-test-device.c
@@ -67,7 +67,7 @@ static void kms_device_probe_screens(struct kms_device *device)
device->screens = calloc(res->count_connectors, sizeof(screen));
if (!device->screens)
- return;
+ goto err_free_resources;
for (i = 0; i < res->count_connectors; i++) {
unsigned int *count;
@@ -97,6 +97,7 @@ static void kms_device_probe_screens(struct kms_device *device)
device->num_screens++;
}
+err_free_resources:
drmModeFreeResources(res);
}
@@ -112,7 +113,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 +124,7 @@ static void kms_device_probe_crtcs(struct kms_device *device)
device->num_crtcs++;
}
+err_free_resources:
drmModeFreeResources(res);
}
@@ -138,7 +140,7 @@ static void kms_device_probe_planes(struct kms_device *device)
device->planes = calloc(res->count_planes, sizeof(plane));
if (!device->planes)
- return;
+ goto err_free_resources;
for (i = 0; i < res->count_planes; i++) {
plane = kms_plane_create(device, res->planes[i]);
@@ -149,6 +151,7 @@ static void kms_device_probe_planes(struct kms_device *device)
device->num_planes++;
}
+err_free_resources:
drmModeFreePlaneResources(res);
}
--
1.9.1
More information about the dri-devel
mailing list