Re: [RESEND PATCH libdrm] tests: fix memory leak issue

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

 



On Tuesday, 2018-03-20 12:47:33 +0900, Inki Dae wrote:
> 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@xxxxxxxxxxx>

Good catch, thanks!
R-b and pushed, since I'm not sure you have commit access on libdrm :)

> ---
>  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
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
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