i965: Check result of make_surface() for miptree_create

Submitted by Andrea Azzarone on April 9, 2018, 11:36 a.m.

Details

Message ID 20180409113620.9138-1-azzaronea@gmail.com
State New
Headers show
Series "i965: Check result of make_surface() for miptree_create" ( rev: 2 ) in Mesa

Not browsing as part of any series.

Commit Message

Andrea Azzarone April 9, 2018, 11:36 a.m.
From: Andrea Azzarone <azzaronea@gmail.com>

Since make_surface() can fail we need to check the result before dereferencing it.
---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 3 +++
 1 file changed, 3 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 23cb40f322..82baf7c356 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -714,6 +714,9 @@  miptree_create(struct brw_context *brw,
          ISL_SURF_USAGE_DEPTH_BIT | ISL_SURF_USAGE_TEXTURE_BIT,
          BO_ALLOC_BUSY, 0, NULL);
 
+      if (!mt)
+         return NULL;
+
       if (needs_separate_stencil(brw, mt, format) &&
           !make_separate_stencil_surface(brw, mt)) {
          intel_miptree_release(&mt);

Comments

CCing: Jason Ekstrand  and Topi Pohjolainen.

2018-04-09 13:36 GMT+02:00 <azzaronea@gmail.com>:

> From: Andrea Azzarone <azzaronea@gmail.com>
>
> Since make_surface() can fail we need to check the result before
> dereferencing it.
> ---
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index 23cb40f322..82baf7c356 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -714,6 +714,9 @@ miptree_create(struct brw_context *brw,
>           ISL_SURF_USAGE_DEPTH_BIT | ISL_SURF_USAGE_TEXTURE_BIT,
>           BO_ALLOC_BUSY, 0, NULL);
>
> +      if (!mt)
> +         return NULL;
> +
>        if (needs_separate_stencil(brw, mt, format) &&
>            !make_separate_stencil_surface(brw, mt)) {
>           intel_miptree_release(&mt);
> --
> 2.17.0
>
>