On Sat, Mar 04, 2023 at 11:45:28AM -0600, Bob Pearson wrote: > This patch adds a WARN_ON if the reference count of the object > passed to __rxe_put() is <= 0. This can only happen if there is a > bug in the rxe driver but has bad consequences if there is. > > Signed-off-by: Bob Pearson <rpearsonhpe@xxxxxxxxx> > --- > drivers/infiniband/sw/rxe/rxe_pool.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c > index 3f6bd672cc2d..1b160e36b751 100644 > --- a/drivers/infiniband/sw/rxe/rxe_pool.c > +++ b/drivers/infiniband/sw/rxe/rxe_pool.c > @@ -244,6 +244,8 @@ int __rxe_get(struct rxe_pool_elem *elem) > > int __rxe_put(struct rxe_pool_elem *elem) > { > + if (WARN_ON(kref_read(&elem->ref_cnt) <= 0)) > + return 0; > return kref_put(&elem->ref_cnt, rxe_elem_release); refcount debugging in kref_put already does this kind of stuff, don't need to open code it. Jason