Module: Mesa Branch: master Commit: 6b676e66343356d5096260c2bc1601014c808cb0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6b676e66343356d5096260c2bc1601014c808cb0
Author: Chad Versace <chad.vers...@linux.intel.com> Date: Wed Jun 26 13:53:15 2013 -0700 i965,i915: Return early if miptree allocation fails 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.roman...@intel.com> Reviewed-by: Anuj Phogat <anuj.pho...@gmail.com> Signed-off-by: Chad Versace <chad.vers...@linux.intel.com> --- src/mesa/drivers/dri/i915/intel_mipmap_tree.c | 2 ++ src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915/intel_mipmap_tree.c index 1776a4b..058cfbe 100644 --- a/src/mesa/drivers/dri/i915/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i915/intel_mipmap_tree.c @@ -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), diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index 1776a4b..058cfbe 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -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), _______________________________________________ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit