diff options
author | Bill Fischofer <bill.fischofer@linaro.org> | 2017-02-02 18:28:02 -0600 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2017-02-10 00:13:16 +0300 |
commit | 0ed479bd9d474f1d7588f3370fb306a2e000ff4f (patch) | |
tree | af8f3b34bd4844dcaf2fa096b1dea4705c8147cd /helper/hashtable.c | |
parent | 483af96a7a14885694496843551ed8fad708192c (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/hashtable.c')
-rw-r--r-- | helper/hashtable.c | 7 |
1 files changed, 5 insertions, 2 deletions
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; |