aboutsummaryrefslogtreecommitdiff
path: root/helper/cuckootable.c
diff options
context:
space:
mode:
authorBill Fischofer <bill.fischofer@linaro.org>2017-02-02 18:28:02 -0600
committerMaxim Uvarov <maxim.uvarov@linaro.org>2017-02-10 00:13:16 +0300
commit0ed479bd9d474f1d7588f3370fb306a2e000ff4f (patch)
treeaf8f3b34bd4844dcaf2fa096b1dea4705c8147cd /helper/cuckootable.c
parent483af96a7a14885694496843551ed8fad708192c (diff)
helper: tables: avoid invalid odp_shm_addr() calls
In the various table lookup routines, check that odp_shm_lookup() returns a valid handle before attempting to dereference it via odp_shm_addr(). Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'helper/cuckootable.c')
-rw-r--r--helper/cuckootable.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/helper/cuckootable.c b/helper/cuckootable.c
index 6a7fb215e..80ff49893 100644
--- a/helper/cuckootable.c
+++ b/helper/cuckootable.c
@@ -151,12 +151,15 @@ align32pow2(uint32_t x)
odph_table_t
odph_cuckoo_table_lookup(const char *name)
{
- odph_cuckoo_table_impl *tbl;
+ odph_cuckoo_table_impl *tbl = NULL;
+ odp_shm_t shm;
if (name == NULL || strlen(name) >= ODPH_TABLE_NAME_LEN)
return NULL;
- tbl = (odph_cuckoo_table_impl *)odp_shm_addr(odp_shm_lookup(name));
+ shm = odp_shm_lookup(name);
+ if (shm != ODP_SHM_INVALID)
+ tbl = (odph_cuckoo_table_impl *)odp_shm_addr(shm);
if (!tbl || tbl->magicword != ODPH_CUCKOO_TABLE_MAGIC_WORD)
return NULL;