From 1ff5463ff83c0a5f6ea6be56056852318bc12d8c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 17 Dec 2020 17:29:13 -0800 Subject: [PATCH] d3d12: Fix memory leak if create_gfx_pipeline_state failed. Fix defect reported by Coverity Scan. Resource leak (RESOURCE_LEAK) leaked_storage: Variable data going out of scope leaks the storage it points to. Fixes: 2ea15cd661c ("d3d12: introduce d3d12 gallium driver") Signed-off-by: Vinson Lee Reviewed-by: Jesse Natalie Reviewed-by: Erik Faye-Lund Part-of: --- src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp b/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp index abea496023f..3d9e7aa6a74 100644 --- a/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp +++ b/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp @@ -312,8 +312,10 @@ d3d12_get_gfx_pipeline_state(struct d3d12_context *ctx) data->key = ctx->gfx_pipeline_state; data->pso = create_gfx_pipeline_state(ctx); - if (!data->pso) + if (!data->pso) { + FREE(data); return NULL; + } entry = _mesa_hash_table_insert_pre_hashed(ctx->pso_cache, hash, &data->key, data); assert(entry);