On Sun, Oct 10, 2021 at 06:59:31PM -0500, Bob Pearson wrote: > diff --git a/drivers/infiniband/sw/rxe/rxe_pool.h b/drivers/infiniband/sw/rxe/rxe_pool.h > index ad287c4ddc1a..43dac03ad82e 100644 > +++ b/drivers/infiniband/sw/rxe/rxe_pool.h > @@ -132,9 +132,20 @@ void *rxe_pool_get_key(struct rxe_pool *pool, void *key); > void rxe_elem_release(struct kref *kref); > > /* take a reference on an object */ > -#define rxe_add_ref(elem) kref_get(&(elem)->pelem.ref_cnt) > +static inline int __rxe_add_ref(struct rxe_pool_entry *elem) > +{ > + int ret = kref_get_unless_zero(&elem->ref_cnt); > + > + if (unlikely(!ret)) > + pr_warn("Taking a reference on a %s object that is already destroyed\n", > + elem->pool->name); There is already debugging prints for this built into the kref, you don't need to open code them Jason