etnaviv: Fix double-free in etna_bo_cache_free()
[mesa.git] / src / etnaviv / drm / etnaviv_cmd_stream.c
index 41350295ef40ca86d4fb8a6fb35aa286cf82791f..e591df297a3ea9068cbbd9b3a8c453e88fc308c3 100644 (file)
@@ -150,11 +150,7 @@ static uint32_t bo2idx(struct etna_cmd_stream *stream, struct etna_bo *bo,
 
        pthread_mutex_lock(&idx_lock);
 
-       if (!bo->current_stream) {
-               idx = append_bo(stream, bo);
-               bo->current_stream = stream;
-               bo->idx = idx;
-       } else if (bo->current_stream == stream) {
+       if (bo->current_stream == stream) {
                idx = bo->idx;
        } else {
                /* slow-path: */
@@ -165,6 +161,8 @@ static uint32_t bo2idx(struct etna_cmd_stream *stream, struct etna_bo *bo,
                        /* not found */
                        idx = append_bo(stream, bo);
                }
+               bo->current_stream = stream;
+               bo->idx = idx;
        }
        pthread_mutex_unlock(&idx_lock);