mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 23:40:10 +01:00
zink: validate pointer alignment in resource_from_user_memory
Signed-off-by: Karol Herbst <kherbst@redhat.com> Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25937>
This commit is contained in:
parent
5e3b7bef1e
commit
049af04341
1 changed files with 8 additions and 0 deletions
|
|
@ -1871,6 +1871,14 @@ zink_resource_from_user_memory(struct pipe_screen *pscreen,
|
|||
const struct pipe_resource *templ,
|
||||
void *user_memory)
|
||||
{
|
||||
struct zink_screen *screen = zink_screen(pscreen);
|
||||
VkDeviceSize alignMask = screen->info.ext_host_mem_props.minImportedHostPointerAlignment - 1;
|
||||
|
||||
/* Validate the user_memory pointer and fail early.
|
||||
* minImportedHostPointerAlignment is required to be POT */
|
||||
if (((uintptr_t)user_memory) & alignMask)
|
||||
return NULL;
|
||||
|
||||
return resource_create(pscreen, templ, NULL, 0, NULL, 0, NULL, user_memory);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue