[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180917123905.213639-11-toddpoynor@gmail.com>
Date: Mon, 17 Sep 2018 05:39:05 -0700
From: Todd Poynor <toddpoynor@...il.com>
To: Rob Springer <rspringer@...gle.com>,
Ben Chan <benchan@...omium.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
Nick Ewalt <nicholasewalt@...gle.com>,
Todd Poynor <toddpoynor@...gle.com>
Subject: [PATCH 10/10] staging: gasket: page_table: handle failed dma_map_page
From: Nick Ewalt <nicholasewalt@...gle.com>
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@...gle.com>
Signed-off-by: Todd Poynor <toddpoynor@...gle.com>
---
drivers/staging/gasket/gasket_page_table.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c
index 8364b49f147c2..964146f0df526 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;
--
2.19.0.397.gdd90340f6a-goog
Powered by blists - more mailing lists