[PATCH v2 5/7] wined3d: Protect wined3d_chunk_vk map fields with a mutex.
Henri Verbeet
hverbeet at gmail.com
Thu Nov 4 07:07:32 CDT 2021
On Thu, 4 Nov 2021 at 06:04, Zebediah Figura <zfigura at codeweavers.com> wrote:
> void *wined3d_allocator_chunk_vk_map(struct wined3d_allocator_chunk_vk *chunk_vk,
> struct wined3d_context_vk *context_vk)
> {
> struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
> const struct wined3d_vk_info *vk_info = context_vk->vk_info;
> + void *map_ptr;
> VkResult vr;
>
> TRACE("chunk %p, memory 0x%s, map_ptr %p.\n", chunk_vk,
> wine_dbgstr_longlong(chunk_vk->vk_memory), chunk_vk->c.map_ptr);
>
> + wined3d_allocator_chunk_vk_lock(chunk_vk);
> +
> if (!chunk_vk->c.map_ptr && (vr = VK_CALL(vkMapMemory(device_vk->vk_device,
> - chunk_vk->vk_memory, 0, VK_WHOLE_SIZE, 0, &chunk_vk->c.map_ptr))) < 0)
> + chunk_vk->vk_memory, 0, VK_WHOLE_SIZE, 0, &map_ptr))) < 0)
> {
> ERR("Failed to map chunk memory, vr %s.\n", wined3d_debug_vkresult(vr));
> return NULL;
> }
> + chunk_vk->c.map_ptr = map_ptr;
>
That doesn't work. If the chunk was already mapped (i.e.,
"chunk_vk->c.map_ptr" isn't NULL), this will overwrite
"chunk_vk->c.map_ptr" with the uninitialised "map_ptr".
More information about the wine-devel
mailing list