aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/gasket/gasket_page_table.c
diff options
context:
space:
mode:
authorNick Ewalt <nicholasewalt@google.com>2018-09-17 05:39:05 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-18 13:22:01 +0200
commit08b6b28801cc5226283a3a1e1fbd3ea4c9ade7c9 (patch)
treee32ddfadd69dbbbe1ab415343f044ec369cfa14c /drivers/staging/gasket/gasket_page_table.c
parentstaging: gasket: page_table: use total_entries for max ext lvl0 page idx (diff)
downloadlinux-dev-08b6b28801cc5226283a3a1e1fbd3ea4c9ade7c9.tar.xz
linux-dev-08b6b28801cc5226283a3a1e1fbd3ea4c9ade7c9.zip
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: Nick Ewalt <nicholasewalt@google.com> Signed-off-by: Todd Poynor <toddpoynor@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/gasket/gasket_page_table.c')
-rw-r--r--drivers/staging/gasket/gasket_page_table.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c
index 8364b49f147c..964146f0df52 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -902,6 +902,17 @@ static int gasket_alloc_extended_subtable(struct gasket_page_table *pg_tbl,
/* Map the page into DMA space. */
pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, PAGE_SIZE,
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 */
dma_addr = (pte->dma_addr + pte->offset) | GASKET_VALID_SLOT_FLAG;