@@ -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;
@@ -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;
@@ -419,11 +419,14 @@ odph_table_t
odph_iplookup_table_lookup(const char *name)
{
odph_iplookup_table_impl *tbl = NULL;
+ odp_shm_t shm;
if (name == NULL || strlen(name) >= ODPH_TABLE_NAME_LEN)
return NULL;
- tbl = (odph_iplookup_table_impl *)odp_shm_addr(odp_shm_lookup(name));
+ shm = odp_shm_lookup(name);
+ if (shm != ODP_SHM_INVALID)
+ tbl = (odph_iplookup_table_impl *)odp_shm_addr(shm);
if (
tbl != NULL &&
@@ -128,12 +128,15 @@ int odph_linear_table_destroy(odph_table_t table)
odph_table_t odph_linear_table_lookup(const char *name)
{
- odph_linear_table_imp *tbl;
+ odph_linear_table_imp *tbl = NULL;
+ odp_shm_t shm;
if (name == NULL || strlen(name) >= ODPH_TABLE_NAME_LEN)
return NULL;
- tbl = (odph_linear_table_imp *)odp_shm_addr(odp_shm_lookup(name));
+ shm = odp_shm_lookup(name);
+ if (shm != ODP_SHM_INVALID)
+ tbl = (odph_linear_table_imp *)odp_shm_addr(shm);
/* check magicword to make sure the memory block is used by a table */
if (tbl != NULL &&
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> --- helper/cuckootable.c | 7 +++++-- helper/hashtable.c | 7 +++++-- helper/iplookuptable.c | 5 ++++- helper/lineartable.c | 7 +++++-- 4 files changed, 19 insertions(+), 7 deletions(-) -- 2.11.0.295.gd7dffce