[Mesa-dev] [PATCH 1/3] egl/dri2: Close file descriptor on error.
Emil Velikov
emil.l.velikov at gmail.com
Fri Jul 17 14:11:55 PDT 2015
On 15/07/15 17:00, Matt Turner wrote:
> ---
> src/egl/drivers/dri2/platform_drm.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
> index 0d1f4c6..a8c5401 100644
> --- a/src/egl/drivers/dri2/platform_drm.c
> +++ b/src/egl/drivers/dri2/platform_drm.c
> @@ -619,18 +619,22 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
> fd = loader_open_device("/dev/dri/card0");
> dri2_dpy->own_device = 1;
> gbm = gbm_create_device(fd);
> - if (gbm == NULL)
> + if (gbm == NULL) {
> + close(fd);
> return EGL_FALSE;
> + }
> }
>
> if (strcmp(gbm_device_get_backend_name(gbm), "drm") != 0) {
> free(dri2_dpy);
> + close(fd);
> return EGL_FALSE;
> }
>
> dri2_dpy->gbm_dri = gbm_dri_device(gbm);
> if (dri2_dpy->gbm_dri->base.type != GBM_DRM_DRIVER_TYPE_DRI) {
> free(dri2_dpy);
> + close(fd);
I don't think we should be closing the device if we don't own it.
-Emil
More information about the mesa-dev
mailing list