From 82eff9db7dc5d8f78898d5051975d14f48be2028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 6 Feb 2007 14:49:40 -0500 Subject: firewire: Use dma_mapping_error() for checking for DMA mapping errors. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pointed out by Pete Zaitcev. Signed-off-by: Kristian Høgsberg Signed-off-by: Stefan Richter --- drivers/firewire/fw-iso.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'drivers/firewire/fw-iso.c') diff --git a/drivers/firewire/fw-iso.c b/drivers/firewire/fw-iso.c index 024fab4ef99..6481e3df2c9 100644 --- a/drivers/firewire/fw-iso.c +++ b/drivers/firewire/fw-iso.c @@ -33,7 +33,7 @@ setup_iso_buffer(struct fw_iso_context *ctx, size_t size, enum dma_data_direction direction) { struct page *page; - int i; + int i, j; void *p; ctx->buffer_size = PAGE_ALIGN(size); @@ -42,24 +42,33 @@ setup_iso_buffer(struct fw_iso_context *ctx, size_t size, ctx->buffer = vmalloc_32_user(ctx->buffer_size); if (ctx->buffer == NULL) - return -ENOMEM; + goto fail_buffer_alloc; ctx->page_count = ctx->buffer_size >> PAGE_SHIFT; ctx->pages = kzalloc(ctx->page_count * sizeof(ctx->pages[0]), GFP_KERNEL); - if (ctx->pages == NULL) { - vfree(ctx->buffer); - return -ENOMEM; - } + if (ctx->pages == NULL) + goto fail_pages_alloc; p = ctx->buffer; for (i = 0; i < ctx->page_count; i++, p += PAGE_SIZE) { page = vmalloc_to_page(p); ctx->pages[i] = dma_map_page(ctx->card->device, page, 0, PAGE_SIZE, direction); + if (dma_mapping_error(ctx->pages[i])) + goto fail_mapping; } return 0; + + fail_mapping: + for (j = 0; j < i; j++) + dma_unmap_page(ctx->card->device, ctx->pages[j], + PAGE_SIZE, DMA_TO_DEVICE); + fail_pages_alloc: + vfree(ctx->buffer); + fail_buffer_alloc: + return -ENOMEM; } static void destroy_iso_buffer(struct fw_iso_context *ctx) -- cgit v1.2.3