[Mesa-dev] [PATCH 05/16] anv: do not try to ref/unref NULL shaders
Iago Toral Quiroga
itoral at igalia.com
Tue Mar 7 07:15:50 UTC 2017
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;
+
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;
+
assert(shader->ref_cnt >= 1);
if (__sync_fetch_and_add(&shader->ref_cnt, -1) == 1)
anv_shader_bin_destroy(device, shader);
--
2.7.4
More information about the mesa-dev
mailing list