Mesa (main): asahi: Fix memory unsafety in delete_sampler_state

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Feb 6 20:55:46 UTC 2022


Module: Mesa
Branch: main
Commit: 0299600efb904c59c91a69cabfc36cfcf6a9ec61
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0299600efb904c59c91a69cabfc36cfcf6a9ec61

Author: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Date:   Sun Feb  6 15:44:35 2022 -0500

asahi: Fix memory unsafety in delete_sampler_state

The type is wrong, masked by a void*, meaning the free is completely
wrong. ASan is rightfully unhappy. Fixes crashes destroying the context.

Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14901>

---

 src/gallium/drivers/asahi/agx_state.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c
index f6f4428c5bd..ab56e86f924 100644
--- a/src/gallium/drivers/asahi/agx_state.c
+++ b/src/gallium/drivers/asahi/agx_state.c
@@ -367,8 +367,8 @@ agx_create_sampler_state(struct pipe_context *pctx,
 static void
 agx_delete_sampler_state(struct pipe_context *ctx, void *state)
 {
-   struct agx_bo *bo = state;
-   agx_bo_unreference(bo);
+   struct agx_sampler_state *so = state;
+   agx_bo_unreference(so->desc);
 }
 
 static void



More information about the mesa-commit mailing list