diff mbox series

[v2,for-next,7/7] RDMA/core: Remove redundant BUG_ON

Message ID 1617783353-48249-8-git-send-email-liweihang@huawei.com (mailing list archive)
State Changes Requested
Delegated to: Jason Gunthorpe
Headers show
Series RDMA/core: Correct some coding-style issues | expand

Commit Message

Weihang Li April 7, 2021, 8:15 a.m. UTC
It's ok if the refcount of cm_id is zero when release the reference of it,
there is no need to call BUG_ON.

Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/core/iwcm.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Jason Gunthorpe April 12, 2021, 5:51 p.m. UTC | #1
On Wed, Apr 07, 2021 at 04:15:53PM +0800, Weihang Li wrote:
> It's ok if the refcount of cm_id is zero when release the reference of it,
> there is no need to call BUG_ON.

Huh? No it isn't.

If you want to remove this BUG_ON then convert this to a refcount_t
and rely on refcount debugging instead.

Jason
Weihang Li April 13, 2021, 3:46 a.m. UTC | #2
On 2021/4/13 1:51, Jason Gunthorpe wrote:
> On Wed, Apr 07, 2021 at 04:15:53PM +0800, Weihang Li wrote:
>> It's ok if the refcount of cm_id is zero when release the reference of it,
>> there is no need to call BUG_ON.
> 
> Huh? No it isn't.
> 
> If you want to remove this BUG_ON then convert this to a refcount_t
> and rely on refcount debugging instead.
> 
> Jason
> 

I see. I will try using refcount_t instead.

Thank you
Weihang
diff mbox series

Patch

diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index da8adad..654ac72 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -211,7 +211,6 @@  static void free_cm_id(struct iwcm_id_private *cm_id_priv)
  */
 static int iwcm_deref_id(struct iwcm_id_private *cm_id_priv)
 {
-	BUG_ON(atomic_read(&cm_id_priv->refcount)==0);
 	if (atomic_dec_and_test(&cm_id_priv->refcount)) {
 		BUG_ON(!list_empty(&cm_id_priv->work_list));
 		free_cm_id(cm_id_priv);