diff mbox series

[v1,11/11] common/dpaax: fix paddr to vaddr invalid conversion

Message ID 20210927132519.19264-12-nipun.gupta@nxp.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series NXP DPAAx Bus and PMD changes | expand


Context Check Description
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/github-robot: build fail github build: failed
ci/intel-Testing success Testing PASS
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Nipun Gupta Sept. 27, 2021, 1:25 p.m. UTC
From: Gagandeep Singh <g.singh@nxp.com>

If some of the VA entries of table are somehow not populated and are
NULL, it can add offset to NULL and return the invalid VA in PA to
VA conversion.

In this patch, adding a check if the VA entry has valid address only
then add offset and return VA.

Fixes: 2f3d633aa593 ("common/dpaax: add library for PA/VA translation table")
Cc: stable@dpdk.org

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
 drivers/common/dpaax/dpaax_iova_table.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series


diff --git a/drivers/common/dpaax/dpaax_iova_table.h b/drivers/common/dpaax/dpaax_iova_table.h
index 230fba8ba0..d7087ee7ca 100644
--- a/drivers/common/dpaax/dpaax_iova_table.h
+++ b/drivers/common/dpaax/dpaax_iova_table.h
@@ -1,5 +1,5 @@ 
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018-2021 NXP
@@ -101,6 +101,12 @@  dpaax_iova_table_get_va(phys_addr_t paddr) {
 		/* paddr > entry->start && paddr <= entry->(start+len) */
 		index = (paddr_align - entry[i].start)/DPAAX_MEM_SPLIT;
+		/* paddr is within range, but no vaddr entry ever written
+		 * at index
+		 */
+		if ((void *)entry[i].pages[index] == NULL)
+			return NULL;
 		vaddr = (void *)((uintptr_t)entry[i].pages[index] + offset);
 	} while (1);