Check for possible hash lookup failure to avoid NULL dereference.
Type: fix
Fixes:
e15c999c30
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: Ib806b4d124be26fbccf36fe9d19af1aec63f487b
}
uword *pu = hash_get (h, root_bus.bus);
- e = pool_elt_at_index (p, (index_t) pu[0]);
+ if (pu)
+ {
+ e = pool_elt_at_index (p, (index_t) pu[0]);
- s = format (s, "IIO%u/%u", e->socket_id, e->iio_unit_id);
+ s = format (s, "IIO%u/%u", e->socket_id, e->iio_unit_id);
+ }
+ else
+ {
+ s = format (s, "[ERR: hash lookup for bus '%u' failed]", root_bus.bus);
+ }
return s;
}