etnaviv: fix use after free in async shader compile
authorLucas Stach <l.stach@pengutronix.de>
Thu, 14 Jul 2022 08:27:05 +0000 (10:27 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 15 Jul 2022 11:07:12 +0000 (11:07 +0000)
commit612b99d721cf8239626589281446bc1d25805490
tree19624e3a83e24c196bdc8e07f2856714d39b859d
parent20350a73a75aac7166b1136ad389f4995175e574
etnaviv: fix use after free in async shader compile

When the shader state is destroyed before the async shader compile is
done, we get a use after free in the async thread, as the shader state
it is operating on is gone. Fix this by dropping any pending job from
the async queue or wait for it to finish before destroying the state
by calling util_queue_drop_job.

Also call util_queue_fence_destroy, which would have caught this issue
by asserting that the queue_fence is in signalled state when the
shader state is destroyed.

Fixes: 1141ed585901 ("etnaviv: async shader compile")
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17534>
src/gallium/drivers/etnaviv/etnaviv_shader.c