[Mesa-dev] [PATCH 05/16] anv: do not try to ref/unref NULL shaders

Jason Ekstrand jason at jlekstrand.net
Tue Mar 7 16:47:46 UTC 2017


On Mon, Mar 6, 2017 at 11:15 PM, Iago Toral Quiroga <itoral at igalia.com>
wrote:

> This situation can happen if we failed to allocate memory for the shader.
> ---
>  src/intel/vulkan/anv_private.h | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_
> private.h
> index c73196a..d3e32bc 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -1551,6 +1551,9 @@ anv_shader_bin_destroy(struct anv_device *device,
> struct anv_shader_bin *shader)
>  static inline void
>  anv_shader_bin_ref(struct anv_shader_bin *shader)
>  {
> +   if (!shader)
> +      return;
>

I don't think this makes sense.


> +
>     assert(shader->ref_cnt >= 1);
>     __sync_fetch_and_add(&shader->ref_cnt, 1);
>  }
> @@ -1558,6 +1561,9 @@ anv_shader_bin_ref(struct anv_shader_bin *shader)
>  static inline void
>  anv_shader_bin_unref(struct anv_device *device, struct anv_shader_bin
> *shader)
>  {
> +   if (!shader)
> +      return;
>

This one is probably ok


> +
>     assert(shader->ref_cnt >= 1);
>     if (__sync_fetch_and_add(&shader->ref_cnt, -1) == 1)
>        anv_shader_bin_destroy(device, shader);
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170307/33e2b5e5/attachment.html>


More information about the mesa-dev mailing list