tests: fix memory leak issue

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@samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
main
Inki Dae 2018-03-20 12:47:33 +09:00 committed by Eric Engestrom
parent ed07718ae7
commit 32e0370e36
1 changed files with 6 additions and 3 deletions

View File

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