On Thu, Dec 16, 2021 at 05:31:55PM -0600, Bob Pearson wrote: > +/** > + * rxe_pool_get_index - lookup object from index > + * @pool: the object pool > + * @index: the index of the object > + * > + * Returns: the object if the index exists in the pool > + * and the reference count on the object is positive > + * else NULL > + */ > +void *rxe_pool_get_index(struct rxe_pool *pool, u32 index) > { > struct rxe_pool_elem *elem; > void *obj; > > + elem = xa_load(&pool->xarray.xa, index); > + if (elem && kref_get_unless_zero(&elem->ref_cnt)) > obj = elem->obj; > + else > obj = NULL; > > return obj; > } This has to hold some kind of lock to protect elem from free while calling kref_get_unless_zero(). You can hold the xa_lock() around this, or use rcu_read_lock(), but that requires using kfree_rcu to free the memory. Jason