From b7e22864aa8a7e2b791119d6be64d208022b42ff Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 23 May 2022 16:50:20 -0700 Subject: [PATCH] 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 Reviewed-by: Adam Jackson Part-of: --- 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;