virgl: free sampler view on failure path
authorDave Airlie <airlied@gmail.com>
Sat, 31 Oct 2015 06:07:52 +0000 (16:07 +1000)
committerDave Airlie <airlied@gmail.com>
Sat, 31 Oct 2015 06:16:44 +0000 (16:16 +1000)
Reported by Coverity.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/virgl/virgl_context.c

index cae6352c0feded3c159b75a4885281d57ce02c07..e4f02ba109668b429c4b2206884e631e420d62a5 100644 (file)
@@ -665,13 +665,17 @@ static struct pipe_sampler_view *virgl_create_sampler_view(struct pipe_context *
                                       const struct pipe_sampler_view *state)
 {
    struct virgl_context *vctx = virgl_context(ctx);
-   struct virgl_sampler_view *grview = CALLOC_STRUCT(virgl_sampler_view);
+   struct virgl_sampler_view *grview;
    uint32_t handle;
    struct virgl_resource *res;
 
    if (state == NULL)
       return NULL;
 
+   grview = CALLOC_STRUCT(virgl_sampler_view);
+   if (!grview)
+      return NULL;
+
    res = virgl_resource(texture);
    handle = virgl_object_assign_handle();
    virgl_encode_sampler_view(vctx, handle, res, state);