From e743a0a252f46dc2e19102b39d3058750a0b1bdb Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Wed, 23 May 2018 19:42:58 +0200 Subject: Fix surface allocation --- surface.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/surface.c b/surface.c index ef701ea..bb6766f 100644 --- a/surface.c +++ b/surface.c @@ -240,7 +240,7 @@ int alloc_surface_buffer(struct doomdev_ioctl_create_surface *params, dma_alloc_coherent(surface_data->doom_data->pci_device, bytes_needed, &surface_data->surface_dev, GFP_KERNEL); - ORFAIL_NULL(surface_data->surface_cpu, -ENOMEM, error_pt); + ORFAIL_NULL(surface_data->surface_cpu, -ENOMEM, error_surface); surface_data->page_table_cpu = dma_alloc_coherent(surface_data->doom_data->pci_device, @@ -258,17 +258,21 @@ int alloc_surface_buffer(struct doomdev_ioctl_create_surface *params, return 0; error_pt: + dma_free_coherent(surface_data->doom_data->pci_device, + surface_data->surface_size, + surface_data->surface_cpu, surface_data->surface_dev); +error_surface: return err; } void free_surface_buffer(struct surface_data *surface_data) { - dma_free_coherent(surface_data->doom_data->device, + dma_free_coherent(surface_data->doom_data->pci_device, surface_data->surface_size, surface_data->surface_cpu, surface_data->surface_dev); - dma_free_coherent(surface_data->doom_data->device, - surface_data->pages, + dma_free_coherent(surface_data->doom_data->pci_device, + surface_data->pages * 4, surface_data->page_table_cpu, surface_data->page_table_dev); } -- cgit v1.2.3