[Mesa-dev] [PATCH] vulkan/wsi/wayland: don't double free on error in get_presentation_support

Eric Engestrom eric.engestrom at intel.com
Fri Oct 5 12:49:46 UTC 2018


On Friday, 2018-10-05 14:10:13 +0200, Philipp Zabel wrote:
> On Fri, 2018-10-05 at 10:13 +1000, Dave Airlie wrote:
> > From: Dave Airlie <airlied at redhat.com>
> > 
> > If we fail the init path then don't call the free path.
> > 
> > Found by coverity
> > ---
> >  src/vulkan/wsi/wsi_common_wayland.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
> > index 6b34e21bd98..ce20583315a 100644
> > --- a/src/vulkan/wsi/wsi_common_wayland.c
> > +++ b/src/vulkan/wsi/wsi_common_wayland.c
> > @@ -455,8 +455,8 @@ wsi_wl_get_presentation_support(struct wsi_device *wsi_device,
> >        (struct wsi_wayland *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
> >  
> >     struct wsi_wl_display display;
> > -   int ret = wsi_wl_display_init(wsi, &display, wl_display, false);
> 
> This removes int ret ...
> 
> > -   wsi_wl_display_finish(&display);
> > +   if (wsi_wl_display_init(wsi, &display, wl_display, false))
> > +      wsi_wl_display_finish(&display);
> >  
> >     return ret == 0;
> 
> ... which is still used here.
> Also it looks like this calls finish in the error case (result != 0).

Agreed.

> 
> Maybe
> 
>     int ret = wsi_wl_display_init(wsi, &display, wl_display, false);
> -   wsi_wl_display_finish(&display);
> +   if (ret == VK_SUCCESS)
> +      wsi_wl_display_finish(&display);
> 
> instead?

That patch would be:
Reviewed-by: Eric Engestrom <eric.engestrom at intel.com>

> 
> regards
> Philipp
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list