llvmpipe: fix use after free with fs variant cleanup

item->base will be freed for the NULL reference write
so just use a temporary to avoid it.

This was found with asan and lavapipe:
dEQP-VK.api.copy_and_blit.core.blit_image*

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8912>
This commit is contained in:
Dave Airlie 2021-02-08 16:52:57 +10:00
parent 2937f69cc0
commit c10b785490

View file

@ -4235,7 +4235,8 @@ llvmpipe_update_fs(struct llvmpipe_context *lp)
assert(item);
assert(item->base);
llvmpipe_remove_shader_variant(lp, item->base);
lp_fs_variant_reference(lp, &item->base, NULL);
struct lp_fragment_shader_variant *variant = item->base;
lp_fs_variant_reference(lp, &variant, NULL);
}
}