diff options
author | Eric Engestrom <[email protected]> | 2017-05-31 16:57:42 +0100 |
---|---|---|
committer | Eric Engestrom <[email protected]> | 2017-05-31 18:09:27 +0100 |
commit | 11da77e5468efd9d02e27e056aeb6abdc56b88b0 (patch) | |
tree | 535b622a037cf3064839284f22a189351043e519 | |
parent | c222fa9ada88980e5613dbca6217219cf0d62d4a (diff) |
egl/drm: remove temporary fd variable
In all codepaths, this var ends up assigned to the struct, except one:
a cleanup codepath, where the `close()` was removed, leading to fd leaks.
Remove the temp fd and assign to the struct field directly instead.
CovID: 1213930
Fixes: 7ec07beedf486d8ab901 ("egl/drm: make use of the
dri2_display_destroy() helper")
Reviewed-by: Emil Velikov <[email protected]>
Signed-off-by: Eric Engestrom <[email protected]>
-rw-r--r-- | src/egl/drivers/dri2/platform_drm.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index c037662f93b..2f045894265 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -672,7 +672,6 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) struct dri2_egl_display *dri2_dpy; struct gbm_device *gbm; const char *err; - int fd = -1; loader_set_logger(_eglLog); @@ -688,18 +687,18 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) char buf[64]; int n = snprintf(buf, sizeof(buf), DRM_DEV_NAME, DRM_DIR_NAME, 0); if (n != -1 && n < sizeof(buf)) - fd = loader_open_device(buf); - if (fd < 0) - fd = loader_open_device("/dev/dri/card0"); - gbm = gbm_create_device(fd); + dri2_dpy->fd = loader_open_device(buf); + if (dri2_dpy->fd < 0) + dri2_dpy->fd = loader_open_device("/dev/dri/card0"); + gbm = gbm_create_device(dri2_dpy->fd); if (gbm == NULL) { err = "DRI2: failed to create gbm device"; goto cleanup; } dri2_dpy->own_device = 1; } else { - fd = fcntl(gbm_device_get_fd(gbm), F_DUPFD_CLOEXEC, 3); - if (fd < 0) { + dri2_dpy->fd = fcntl(gbm_device_get_fd(gbm), F_DUPFD_CLOEXEC, 3); + if (dri2_dpy->fd < 0) { err = "DRI2: failed to fcntl() existing gbm device"; goto cleanup; } @@ -711,7 +710,6 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) } dri2_dpy->gbm_dri = gbm_dri_device(gbm); - dri2_dpy->fd = fd; dri2_dpy->driver_name = strdup(dri2_dpy->gbm_dri->driver_name); dri2_dpy->dri_screen = dri2_dpy->gbm_dri->screen; |