anv: do not try to ref/unref NULL shaders

This situation can happen if we failed to allocate memory for the shader.

v2:
 - We shouldn't see NULL shaders in anv_shader_bin_ref so we should not check
   for that (Jason). Make sure that callers don't attempt to call this
   function with a NULL shader and assert that this never happens (Iago).

v3:
 - All callers to anv_shader_bin_unref seem to check for NULL before calling,
   so just assert that it is not NULL (Topi)

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
This commit is contained in:
Iago Toral Quiroga
2017-03-03 10:57:17 +01:00
parent bad3a2e911
commit 88b539c4a0
2 changed files with 6 additions and 3 deletions

View File

@@ -308,7 +308,8 @@ anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
pthread_mutex_unlock(&cache->mutex);
/* We increment refcount before handing it to the caller */
anv_shader_bin_ref(bin);
if (bin)
anv_shader_bin_ref(bin);
return bin;
} else {
@@ -546,6 +547,8 @@ VkResult anv_MergePipelineCaches(
struct hash_entry *entry;
hash_table_foreach(src->cache, entry) {
struct anv_shader_bin *bin = entry->data;
assert(bin);
if (_mesa_hash_table_search(dst->cache, bin->key))
continue;