From 0ed479bd9d474f1d7588f3370fb306a2e000ff4f Mon Sep 17 00:00:00 2001 From: Bill Fischofer Date: Thu, 2 Feb 2017 18:28:02 -0600 Subject: 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 Signed-off-by: Maxim Uvarov --- helper/hashtable.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'helper/hashtable.c') diff --git a/helper/hashtable.c b/helper/hashtable.c index 1c2b85234..9d4114445 100644 --- a/helper/hashtable.c +++ b/helper/hashtable.c @@ -150,12 +150,15 @@ int odph_hash_table_destroy(odph_table_t table) odph_table_t odph_hash_table_lookup(const char *name) { - odph_hash_table_imp *hash_tbl; + odph_hash_table_imp *hash_tbl = NULL; + odp_shm_t shm; if (name == NULL || strlen(name) >= ODPH_TABLE_NAME_LEN) return NULL; - hash_tbl = (odph_hash_table_imp *)odp_shm_addr(odp_shm_lookup(name)); + shm = odp_shm_lookup(name); + if (shm != ODP_SHM_INVALID) + hash_tbl = (odph_hash_table_imp *)odp_shm_addr(shm); if (hash_tbl != NULL && strcmp(hash_tbl->name, name) == 0) return (odph_table_t)hash_tbl; return NULL; -- cgit v1.2.3