OSDN Git Service

i965,i915: Return early if miptree allocation fails
authorChad Versace <chad.versace@linux.intel.com>
Wed, 26 Jun 2013 20:53:15 +0000 (13:53 -0700)
committerChad Versace <chad.versace@linux.intel.com>
Thu, 27 Jun 2013 20:16:47 +0000 (13:16 -0700)
If allocation fails in intel_miptree_create_layout(), don't proceed to
dereference the miptree. Return an early NULL.

Fixes static analysis error reported by Klocwork.

Note: This is a candidate for the 9.1 branch.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
src/mesa/drivers/dri/i915/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.c

index 1776a4b..058cfbe 100644 (file)
@@ -260,6 +260,8 @@ intel_miptree_create_layout(struct intel_context *intel,
                             GLuint num_samples)
 {
    struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1);
+   if (!mt)
+      return NULL;
 
    DBG("%s target %s format %s level %d..%d <-- %p\n", __FUNCTION__,
        _mesa_lookup_enum_by_nr(target),
index 1776a4b..058cfbe 100644 (file)
@@ -260,6 +260,8 @@ intel_miptree_create_layout(struct intel_context *intel,
                             GLuint num_samples)
 {
    struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1);
+   if (!mt)
+      return NULL;
 
    DBG("%s target %s format %s level %d..%d <-- %p\n", __FUNCTION__,
        _mesa_lookup_enum_by_nr(target),