aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-iso.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firewire/fw-iso.c')
-rw-r--r--drivers/firewire/fw-iso.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/firewire/fw-iso.c b/drivers/firewire/fw-iso.c
index 024fab4ef998..6481e3df2c93 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,
33 enum dma_data_direction direction) 33 enum dma_data_direction direction)
34{ 34{
35 struct page *page; 35 struct page *page;
36 int i; 36 int i, j;
37 void *p; 37 void *p;
38 38
39 ctx->buffer_size = PAGE_ALIGN(size); 39 ctx->buffer_size = PAGE_ALIGN(size);
@@ -42,24 +42,33 @@ setup_iso_buffer(struct fw_iso_context *ctx, size_t size,
42 42
43 ctx->buffer = vmalloc_32_user(ctx->buffer_size); 43 ctx->buffer = vmalloc_32_user(ctx->buffer_size);
44 if (ctx->buffer == NULL) 44 if (ctx->buffer == NULL)
45 return -ENOMEM; 45 goto fail_buffer_alloc;
46 46
47 ctx->page_count = ctx->buffer_size >> PAGE_SHIFT; 47 ctx->page_count = ctx->buffer_size >> PAGE_SHIFT;
48 ctx->pages = 48 ctx->pages =
49 kzalloc(ctx->page_count * sizeof(ctx->pages[0]), GFP_KERNEL); 49 kzalloc(ctx->page_count * sizeof(ctx->pages[0]), GFP_KERNEL);
50 if (ctx->pages == NULL) { 50 if (ctx->pages == NULL)
51 vfree(ctx->buffer); 51 goto fail_pages_alloc;
52 return -ENOMEM;
53 }
54 52
55 p = ctx->buffer; 53 p = ctx->buffer;
56 for (i = 0; i < ctx->page_count; i++, p += PAGE_SIZE) { 54 for (i = 0; i < ctx->page_count; i++, p += PAGE_SIZE) {
57 page = vmalloc_to_page(p); 55 page = vmalloc_to_page(p);
58 ctx->pages[i] = dma_map_page(ctx->card->device, 56 ctx->pages[i] = dma_map_page(ctx->card->device,
59 page, 0, PAGE_SIZE, direction); 57 page, 0, PAGE_SIZE, direction);
58 if (dma_mapping_error(ctx->pages[i]))
59 goto fail_mapping;
60 } 60 }
61 61
62 return 0; 62 return 0;
63
64 fail_mapping:
65 for (j = 0; j < i; j++)
66 dma_unmap_page(ctx->card->device, ctx->pages[j],
67 PAGE_SIZE, DMA_TO_DEVICE);
68 fail_pages_alloc:
69 vfree(ctx->buffer);
70 fail_buffer_alloc:
71 return -ENOMEM;
63} 72}
64 73
65static void destroy_iso_buffer(struct fw_iso_context *ctx) 74static void destroy_iso_buffer(struct fw_iso_context *ctx)