Module: Mesa Branch: main Commit: b7e22864aa8a7e2b791119d6be64d208022b42ff URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b7e22864aa8a7e2b791119d6be64d208022b42ff
Author: Vinson Lee <[email protected]> Date: Mon May 23 16:50:20 2022 -0700 dri2: Fix memory leak. Fix defect reported by Coverity Scan. Resource leak (RESOURCE_LEAK) leaked_storage: Variable psp going out of scope leaks the storage it points to. Fixes: 68aa2099fa4 ("dri2: Require a loader with working buffer invalidation") Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Adam Jackson <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16680> --- src/gallium/frontends/dri/dri_util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/dri/dri_util.c b/src/gallium/frontends/dri/dri_util.c index bdaedf12594..4207eff3f43 100644 --- a/src/gallium/frontends/dri/dri_util.c +++ b/src/gallium/frontends/dri/dri_util.c @@ -122,8 +122,10 @@ driCreateNewScreen2(int scrn, int fd, setupLoaderExtensions(psp, extensions); // dri2 drivers require working invalidate - if (fd != -1 && !psp->dri2.useInvalidate) + if (fd != -1 && !psp->dri2.useInvalidate) { + free(psp); return NULL; + } psp->loaderPrivate = data;
