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

Iago Toral itoral at igalia.com
Wed Mar 8 08:31:21 UTC 2017


On Tue, 2017-03-07 at 08:47 -0800, Jason Ekstrand wrote:
> On Mon, Mar 6, 2017 at 11:15 PM, Iago Toral Quiroga <itoral at igalia.co
> m> 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.

Ok, in that case I'll replace this with an assert that shader != NULL.


> > +
> >     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
> > 


More information about the mesa-dev mailing list