diff mbox series

common/dpaax: fix uninitialized table case

Message ID 20181017090517.14530-1-shreyansh.jain@nxp.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series common/dpaax: fix uninitialized table case | expand

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Shreyansh Jain Oct. 17, 2018, 9:05 a.m. UTC
There is a possibility that either because of missing device tree entry
or lack of memory, the PA-VA table might not be available. But, the
table being transparent, the callers don't necessary check for its
initialization state. This is explicitly done during update and
translation call.

Fixes: 2f3d633aa593 ("common/dpaax: add library for PA/VA translation table")

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/common/dpaax/dpaax_iova_table.c | 3 +++
 drivers/common/dpaax/dpaax_iova_table.h | 3 +++
 2 files changed, 6 insertions(+)

Comments

Thomas Monjalon Oct. 24, 2018, 10:32 p.m. UTC | #1
17/10/2018 11:05, Shreyansh Jain:
> There is a possibility that either because of missing device tree entry
> or lack of memory, the PA-VA table might not be available. But, the
> table being transparent, the callers don't necessary check for its
> initialization state. This is explicitly done during update and
> translation call.
> 
> Fixes: 2f3d633aa593 ("common/dpaax: add library for PA/VA translation table")
> 
> Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>

Applied, thanks
diff mbox series

Patch

diff --git a/drivers/common/dpaax/dpaax_iova_table.c b/drivers/common/dpaax/dpaax_iova_table.c
index d54267bb7..075053b1a 100644
--- a/drivers/common/dpaax/dpaax_iova_table.c
+++ b/drivers/common/dpaax/dpaax_iova_table.c
@@ -272,6 +272,9 @@  dpaax_iova_table_update(phys_addr_t paddr, void *vaddr, size_t length)
 	uintptr_t align_vaddr;
 	phys_addr_t align_paddr;
 
+	if (unlikely(dpaax_iova_table_p == NULL))
+		return -1;
+
 	align_paddr = paddr & DPAAX_MEM_SPLIT_MASK;
 	align_vaddr = ((uintptr_t)vaddr & DPAAX_MEM_SPLIT_MASK);
 
diff --git a/drivers/common/dpaax/dpaax_iova_table.h b/drivers/common/dpaax/dpaax_iova_table.h
index 1109a362c..138827e7b 100644
--- a/drivers/common/dpaax/dpaax_iova_table.h
+++ b/drivers/common/dpaax/dpaax_iova_table.h
@@ -74,6 +74,9 @@  dpaax_iova_table_get_va(phys_addr_t paddr) {
 	size_t offset = paddr & DPAAX_MEM_SPLIT_MASK_OFF;
 	struct dpaax_iovat_element *entry;
 
+	if (unlikely(dpaax_iova_table_p == NULL))
+		return NULL;
+
 	entry = dpaax_iova_table_p->entries;
 
 	do {