drisw: don't leak the winsys
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 10 Apr 2023 13:47:06 +0000 (09:47 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 20 Apr 2023 13:34:15 +0000 (13:34 +0000)
if a winsys is allocated by the frontend, it should be freed by the frontend
rather than the driver to ensure it doesn't leak if it doesn't reach
the driver

cc: mesa-stable

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22396>

src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/softpipe/sp_screen.c

index 75a247d..e11837f 100644 (file)
@@ -382,6 +382,7 @@ pipe_loader_sw_release(struct pipe_loader_device **dev)
    UNUSED struct pipe_loader_sw_device *sdev =
       pipe_loader_sw_device(*dev);
 
+   sdev->ws->destroy(sdev->ws);
 #ifndef GALLIUM_STATIC_TARGETS
    if (sdev->lib)
       util_dl_close(sdev->lib);
index 2ffc941..7d5e5c7 100644 (file)
@@ -860,7 +860,6 @@ static void
 llvmpipe_destroy_screen(struct pipe_screen *_screen)
 {
    struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
-   struct sw_winsys *winsys = screen->winsys;
 
    if (screen->cs_tpool)
       lp_cs_tpool_destroy(screen->cs_tpool);
@@ -871,8 +870,6 @@ llvmpipe_destroy_screen(struct pipe_screen *_screen)
    lp_jit_screen_cleanup(screen);
 
    disk_cache_destroy(screen->disk_shader_cache);
-   if (winsys->destroy)
-      winsys->destroy(winsys);
 
    glsl_type_singleton_decref();
 
index 7bd792f..74ff914 100644 (file)
@@ -490,12 +490,6 @@ softpipe_is_format_supported( struct pipe_screen *screen,
 static void
 softpipe_destroy_screen( struct pipe_screen *screen )
 {
-   struct softpipe_screen *sp_screen = softpipe_screen(screen);
-   struct sw_winsys *winsys = sp_screen->winsys;
-
-   if(winsys->destroy)
-      winsys->destroy(winsys);
-
    FREE(screen);
 }