Commit 08b6b288 authored by Nick Ewalt's avatar Nick Ewalt Committed by Greg Kroah-Hartman

staging: gasket: page_table: handle failed dma_map_page

Handle dma_map_page failing in gasket_alloc_extended_subtable: free
memory, don't add invalid page table entry.
Signed-off-by: default avatarNick Ewalt <nicholasewalt@google.com>
Signed-off-by: default avatarTodd Poynor <toddpoynor@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0eaf57fb
...@@ -902,6 +902,17 @@ static int gasket_alloc_extended_subtable(struct gasket_page_table *pg_tbl, ...@@ -902,6 +902,17 @@ static int gasket_alloc_extended_subtable(struct gasket_page_table *pg_tbl,
/* Map the page into DMA space. */ /* Map the page into DMA space. */
pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, PAGE_SIZE, pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, PAGE_SIZE,
DMA_TO_DEVICE); DMA_TO_DEVICE);
if (dma_mapping_error(pg_tbl->device, pte->dma_addr)) {
dev_dbg(pg_tbl->device,
"%s: fail to map page [pfn %lx phys %llx]\n",
__func__, page_to_pfn(pte->page),
page_to_phys(pte->page));
free_page(page_addr);
vfree(pte->sublevel);
memset(pte, 0, sizeof(struct gasket_page_table_entry));
return -ENOMEM;
}
/* make the addresses available to the device */ /* make the addresses available to the device */
dma_addr = (pte->dma_addr + pte->offset) | GASKET_VALID_SLOT_FLAG; dma_addr = (pte->dma_addr + pte->offset) | GASKET_VALID_SLOT_FLAG;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment