dmabuf: fix mmap() calls

* We cannot map with offset, because offsets need to be page-size
  aligned. And our code doesn't expect an offset anyway.
* The error return value from mmap() is MAP_FAILED aka -1, not NULL aka
  0.
This commit is contained in:
Benjamin Otte 2024-07-18 04:31:00 +02:00
parent 1afb832ff0
commit 619926ec83

View File

@ -2134,8 +2134,8 @@ gdk_dmabuf_do_download_mmap (GdkTexture *texture,
if (gdk_dmabuf_ioctl (dmabuf->planes[i].fd, DMA_BUF_IOCTL_SYNC, &(struct dma_buf_sync) { DMA_BUF_SYNC_START|DMA_BUF_SYNC_READ }) < 0)
g_warning ("Failed to sync dmabuf: %s", g_strerror (errno));
src_data[i] = mmap (NULL, sizes[i], PROT_READ, MAP_SHARED, dmabuf->planes[i].fd, dmabuf->planes[i].offset);
if (src_data[i] == NULL)
src_data[i] = mmap (NULL, sizes[i], PROT_READ, MAP_SHARED, dmabuf->planes[i].fd, 0);
if (src_data[i] == NULL || src_data[i] == MAP_FAILED)
{
g_warning ("Failed to mmap dmabuf: %s", g_strerror (errno));
goto out;