aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorInki Dae2018-03-19 22:47:33 -0500
committerEric Engestrom2018-03-20 09:14:51 -0500
commit32e0370e36e8263b1e7dfb75f76934dbfce53e9c (patch)
treee5ae2a16f419c9a5b10b24178aaff2115c246300 /tests
parented07718ae7bab596297abf210bb0c37c6dba58ed (diff)
downloadexternal-libdrm-32e0370e36e8263b1e7dfb75f76934dbfce53e9c.tar.gz
external-libdrm-32e0370e36e8263b1e7dfb75f76934dbfce53e9c.tar.xz
external-libdrm-32e0370e36e8263b1e7dfb75f76934dbfce53e9c.zip
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>
Diffstat (limited to 'tests')
-rw-r--r--tests/kms/libkms-test-device.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/kms/libkms-test-device.c b/tests/kms/libkms-test-device.c
index 53c7349b..042ae05d 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)
67 67
68 device->screens = calloc(res->count_connectors, sizeof(screen)); 68 device->screens = calloc(res->count_connectors, sizeof(screen));
69 if (!device->screens) 69 if (!device->screens)
70 return; 70 goto err_free_resources;
71 71
72 for (i = 0; i < res->count_connectors; i++) { 72 for (i = 0; i < res->count_connectors; i++) {
73 unsigned int *count; 73 unsigned int *count;
@@ -97,6 +97,7 @@ static void kms_device_probe_screens(struct kms_device *device)
97 device->num_screens++; 97 device->num_screens++;
98 } 98 }
99 99
100err_free_resources:
100 drmModeFreeResources(res); 101 drmModeFreeResources(res);
101} 102}
102 103
@@ -112,7 +113,7 @@ static void kms_device_probe_crtcs(struct kms_device *device)
112 113
113 device->crtcs = calloc(res->count_crtcs, sizeof(crtc)); 114 device->crtcs = calloc(res->count_crtcs, sizeof(crtc));
114 if (!device->crtcs) 115 if (!device->crtcs)
115 return; 116 goto err_free_resources;
116 117
117 for (i = 0; i < res->count_crtcs; i++) { 118 for (i = 0; i < res->count_crtcs; i++) {
118 crtc = kms_crtc_create(device, res->crtcs[i]); 119 crtc = kms_crtc_create(device, res->crtcs[i]);
@@ -123,6 +124,7 @@ static void kms_device_probe_crtcs(struct kms_device *device)
123 device->num_crtcs++; 124 device->num_crtcs++;
124 } 125 }
125 126
127err_free_resources:
126 drmModeFreeResources(res); 128 drmModeFreeResources(res);
127} 129}
128 130
@@ -138,7 +140,7 @@ static void kms_device_probe_planes(struct kms_device *device)
138 140
139 device->planes = calloc(res->count_planes, sizeof(plane)); 141 device->planes = calloc(res->count_planes, sizeof(plane));
140 if (!device->planes) 142 if (!device->planes)
141 return; 143 goto err_free_resources;
142 144
143 for (i = 0; i < res->count_planes; i++) { 145 for (i = 0; i < res->count_planes; i++) {
144 plane = kms_plane_create(device, res->planes[i]); 146 plane = kms_plane_create(device, res->planes[i]);
@@ -149,6 +151,7 @@ static void kms_device_probe_planes(struct kms_device *device)
149 device->num_planes++; 151 device->num_planes++;
150 } 152 }
151 153
154err_free_resources:
152 drmModeFreePlaneResources(res); 155 drmModeFreePlaneResources(res);
153} 156}
154 157