[Mesa-dev] [PATCH] i965, i915: Return early if miptree allocation fails
Ian Romanick
idr at freedesktop.org
Wed Jun 26 14:57:47 PDT 2013
On 06/26/2013 02:42 PM, Chad Versace wrote:
> 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.
> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Too bad this didn't land before the split. The cherry-pick will
probably be annoying now. :( Alas.
> ---
> 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(+)
>
> 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),
>
More information about the mesa-dev
mailing list