[Mesa-dev] [PATCH 1/3] st/dri: don't call close(-1) in dri{2, kms_}_init_screen error path
Leo Liu
leo.liu at amd.com
Sun May 15 01:12:35 UTC 2016
Series is:
Reviewed-by: Leo Liu <leo.liu at amd.com>
On 05/14/2016 11:33 AM, Emil Velikov wrote:
> Add separate labels and jump to the correct one as needed.
>
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
> ---
> src/gallium/state_trackers/dri/dri2.c | 30 ++++++++++++++++++++----------
> 1 file changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
> index 675a9bb..2330530 100644
> --- a/src/gallium/state_trackers/dri/dri2.c
> +++ b/src/gallium/state_trackers/dri/dri2.c
> @@ -1714,7 +1714,7 @@ dri2_init_screen(__DRIscreen * sPriv)
> struct pipe_screen *pscreen = NULL;
> const struct drm_conf_ret *throttle_ret;
> const struct drm_conf_ret *dmabuf_ret;
> - int fd = -1;
> + int fd;
>
> screen = CALLOC_STRUCT(dri_screen);
> if (!screen)
> @@ -1727,13 +1727,13 @@ dri2_init_screen(__DRIscreen * sPriv)
> sPriv->driverPrivate = (void *)screen;
>
> if (screen->fd < 0 || (fd = dup(screen->fd)) < 0)
> - goto fail;
> + goto free_screen;
>
> if (pipe_loader_drm_probe_fd(&screen->dev, fd))
> pscreen = pipe_loader_create_screen(screen->dev);
>
> if (!pscreen)
> - goto fail;
> + goto release_pipe;
>
> throttle_ret = pipe_loader_configuration(screen->dev, DRM_CONF_THROTTLE);
> dmabuf_ret = pipe_loader_configuration(screen->dev, DRM_CONF_SHARE_FD);
> @@ -1762,7 +1762,7 @@ dri2_init_screen(__DRIscreen * sPriv)
>
> configs = dri_init_screen_helper(screen, pscreen, screen->dev->driver_name);
> if (!configs)
> - goto fail;
> + goto destroy_screen;
>
> screen->can_share_buffer = true;
> screen->auto_fake_front = dri_with_format(sPriv);
> @@ -1770,12 +1770,17 @@ dri2_init_screen(__DRIscreen * sPriv)
> screen->lookup_egl_image = dri2_lookup_egl_image;
>
> return configs;
> -fail:
> +
> +destroy_screen:
> dri_destroy_screen_helper(screen);
> +
> +release_pipe:
> if (screen->dev)
> pipe_loader_release(&screen->dev, 1);
> else
> close(fd);
> +
> +free_screen:
> FREE(screen);
> return NULL;
> }
> @@ -1793,7 +1798,7 @@ dri_kms_init_screen(__DRIscreen * sPriv)
> struct dri_screen *screen;
> struct pipe_screen *pscreen = NULL;
> uint64_t cap;
> - int fd = -1;
> + int fd;
>
> screen = CALLOC_STRUCT(dri_screen);
> if (!screen)
> @@ -1805,13 +1810,13 @@ dri_kms_init_screen(__DRIscreen * sPriv)
> sPriv->driverPrivate = (void *)screen;
>
> if (screen->fd < 0 || (fd = dup(screen->fd)) < 0)
> - goto fail;
> + goto free_screen;
>
> if (pipe_loader_sw_probe_kms(&screen->dev, fd))
> pscreen = pipe_loader_create_screen(screen->dev);
>
> if (!pscreen)
> - goto fail;
> + goto release_pipe;
>
> if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
> (cap & DRM_PRIME_CAP_IMPORT)) {
> @@ -1823,7 +1828,7 @@ dri_kms_init_screen(__DRIscreen * sPriv)
>
> configs = dri_init_screen_helper(screen, pscreen, "swrast");
> if (!configs)
> - goto fail;
> + goto destroy_screen;
>
> screen->can_share_buffer = false;
> screen->auto_fake_front = dri_with_format(sPriv);
> @@ -1831,12 +1836,17 @@ dri_kms_init_screen(__DRIscreen * sPriv)
> screen->lookup_egl_image = dri2_lookup_egl_image;
>
> return configs;
> -fail:
> +
> +destroy_screen:
> dri_destroy_screen_helper(screen);
> +
> +release_pipe:
> if (screen->dev)
> pipe_loader_release(&screen->dev, 1);
> else
> close(fd);
> +
> +free_screen:
> FREE(screen);
> #endif // GALLIUM_SOFTPIPE
> return NULL;
More information about the mesa-dev
mailing list