From: Shreyansh Jain <shreyansh.jain@nxp.com>
To: "thomas@monjalon.net" <thomas@monjalon.net>
Cc: "dev@dpdk.org" <dev@dpdk.org>, Shreyansh Jain <shreyansh.jain@nxp.com>
Subject: [dpdk-dev] [PATCH] common/dpaax: fix uninitialized table case
Date: Wed, 17 Oct 2018 09:05:57 +0000 [thread overview]
Message-ID: <20181017090517.14530-1-shreyansh.jain@nxp.com> (raw)
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(+)
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 {
--
2.17.1
next reply other threads:[~2018-10-17 9:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-17 9:05 Shreyansh Jain [this message]
2018-10-24 22:32 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181017090517.14530-1-shreyansh.jain@nxp.com \
--to=shreyansh.jain@nxp.com \
--cc=dev@dpdk.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).