aboutsummaryrefslogtreecommitdiffstats
path: root/src/amd
diff options
context:
space:
mode:
authorRhys Perry <[email protected]>2019-09-24 17:21:51 +0100
committerRhys Perry <[email protected]>2020-01-13 13:25:32 +0000
commitbbac52873f4248c2f545f12137bd24071a8043cc (patch)
tree238bfb3a53f7f48a8ef54a54826d21d78ebcb0ff /src/amd
parentfcd6d8324560b5897586cbf8161f9b46bff5d11f (diff)
aco: fix uninitialized data in the binary
Signed-off-by: Rhys Perry <[email protected]> Reviewed-By: Timur Kristóf <[email protected]> Fixes: 93c8ebfa780 ('aco: Initial commit of independent AMD compiler') Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3081>
Diffstat (limited to 'src/amd')
-rw-r--r--src/amd/compiler/aco_interface.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/amd/compiler/aco_interface.cpp b/src/amd/compiler/aco_interface.cpp
index 802adcefb1b..f951c4fdc5f 100644
--- a/src/amd/compiler/aco_interface.cpp
+++ b/src/amd/compiler/aco_interface.cpp
@@ -154,7 +154,11 @@ void aco_compile_shader(unsigned shader_count,
}
size += code.size() * sizeof(uint32_t) + sizeof(radv_shader_binary_legacy);
- radv_shader_binary_legacy* legacy_binary = (radv_shader_binary_legacy*) malloc(size);
+ /* We need to calloc to prevent unintialized data because this will be used
+ * directly for the disk cache. Uninitialized data can appear because of
+ * padding in the struct or because legacy_binary->data can be at an offset
+ * from the start less than sizeof(radv_shader_binary_legacy). */
+ radv_shader_binary_legacy* legacy_binary = (radv_shader_binary_legacy*) calloc(size, 1);
legacy_binary->base.type = RADV_BINARY_TYPE_LEGACY;
legacy_binary->base.stage = shaders[shader_count-1]->info.stage;