[Mesa-dev] [PATCH] st/dri: Fix memory leak on error path.

Vinson Lee vlee at vmware.com
Sat Nov 5 22:23:30 PDT 2011


Fixes Coverity resource leak defect.
---
 src/gallium/state_trackers/dri/drm/dri2.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index a6bf3c1..4e3f106 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -306,8 +306,10 @@ dri2_allocate_buffer(__DRIscreen *sPriv,
 
    buffer->resource =
       screen->base.screen->resource_create(screen->base.screen, &templ);
-   if (!buffer->resource)
+   if (!buffer->resource) {
+      FREE(buffer);
       return NULL;
+   }
 
    memset(&whandle, 0, sizeof(whandle));
    whandle.type = DRM_API_HANDLE_TYPE_SHARED;
-- 
1.7.7



More information about the mesa-dev mailing list