[Mesa-dev] [PATCH] winsys/radeon: don't leak the fd when it is 0

Alex Deucher alexdeucher at gmail.com
Wed Jul 29 08:46:51 PDT 2015


On Wed, Jul 29, 2015 at 10:44 AM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
> Earlier commit added an extra dup(fd) to fix a ZaphodHeads issue.
> Although it did not consider the (very unlikely) case where we might end
> up with the valid fd == 0.
>
> Fixes: 28dda47ae4d(winsys/radeon: Use dup fd as key in drm-winsys hash
> table to fix ZaphodHeads.)
>
> Cc: Mario Kleiner <mario.kleiner.de at gmail.com>
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>
> Perhaps we should CC mesa-stable as the offending commit, yet
> considering how unlikely the above case is I'm ambivalent,
>
> -Emil
>
>  src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
> index 41f8826..f7784fb 100644
> --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
> +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
> @@ -493,7 +493,7 @@ static void radeon_winsys_destroy(struct radeon_winsys *rws)
>          radeon_surface_manager_free(ws->surf_man);
>      }
>
> -    if (ws->fd)
> +    if (ws->fd >= 0)
>          close(ws->fd);
>
>      FREE(rws);
> @@ -786,7 +786,7 @@ fail:
>          ws->kman->destroy(ws->kman);
>      if (ws->surf_man)
>          radeon_surface_manager_free(ws->surf_man);
> -    if (ws->fd)
> +    if (ws->fd >= 0)
>          close(ws->fd);
>
>      FREE(ws);
> --
> 2.4.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list