Module: Mesa
Branch: staging/21.0
Commit: 5450f1850b153dae1b37f8e541b8310baaba4b7c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5450f1850b153dae1b37f8e541b8310baaba4b7c

Author: Adam Jackson <[email protected]>
Date:   Tue May 11 11:07:20 2021 -0400

zink/ntv: Don't call free() on ralloc'd memory

Caught this with an LTO build:

[1465/1465] Linking target src/gallium/targets/dri/libgallium_dri.so
In function ‘spirv_shader_delete’,
    inlined from ‘nir_to_spirv’ at 
../src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c:3907:7:
../src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c:3916:4: warning: ‘free’ 
called on pointer ‘block_1394’ with nonzero offset 48 [-Wfree-nonheap-object]
 3916 |    FREE(s);
      |    ^
../src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c: In function 
‘nir_to_spirv’:
../src/util/ralloc.c:133:18: note: returned from ‘malloc’
  133 |    void *block = malloc(align64(size + sizeof(ralloc_header),
      |                  ^

Since s->words is allocated on the same ralloc context we can simplify
further by freeing the context all at once.

Reviewed-by: Emma Anholt <[email protected]>
Reviewed-by: Mike Blumenkrantz <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10857>

---

 src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c 
b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
index 32d06ada3b1..9b0a3e4db5e 100644
--- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
+++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
@@ -2979,6 +2979,5 @@ fail:
 void
 spirv_shader_delete(struct spirv_shader *s)
 {
-   FREE(s->words);
-   FREE(s);
+   ralloc_free(s);
 }

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to