Re: [PATCH V3 12/18] RDMA/siw: Introduce siw_free_cm_id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 10/27/23 20:40, Bernard Metzler wrote:

-----Original Message-----
From: Guoqing Jiang <guoqing.jiang@xxxxxxxxx>
Sent: Friday, October 27, 2023 4:33 AM
To: Bernard Metzler <BMT@xxxxxxxxxxxxxx>; jgg@xxxxxxxx; leon@xxxxxxxxxx
Cc: linux-rdma@xxxxxxxxxxxxxxx
Subject: [EXTERNAL] [PATCH V3 12/18] RDMA/siw: Introduce siw_free_cm_id

Factor out a helper to simplify code.

Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: INVALID URI REMOVED
3A__lore.kernel.org_oe-2Dkbuild-2Dall_202310091656.JlrmcNXB-2Dlkp-
40intel.com_&d=DwIDAg&c=jf_iaSHvJObTbx-siA1ZOg&r=2TaYXQ0T-
r8ZO1PP1alNwU_QJcRRLfmYTAgd3QCvqSc&m=jcLol9KAEfaBk2TluRpduOxKYYBXhnRmUiRsGk
F1es3nam0Db9DqJGrHbGh6Dxev&s=046yLPELHuHW8OJFi9dwmPygAP11lnZQi6DpfngHzJ8&e=
Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxx>
---
  drivers/infiniband/sw/siw/siw_cm.c | 34 +++++++++++++-----------------
  1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/infiniband/sw/siw/siw_cm.c
b/drivers/infiniband/sw/siw/siw_cm.c
index 2f338bb3a24c..1d2438fbf7c7 100644
--- a/drivers/infiniband/sw/siw/siw_cm.c
+++ b/drivers/infiniband/sw/siw/siw_cm.c
@@ -364,6 +364,15 @@ static int siw_cm_upcall(struct siw_cep *cep, enum
iw_cm_event_type reason,
  	return id->event_handler(id, &event);
  }

+static void siw_free_cm_id(struct siw_cep *cep)
+{
+	if (!cep->cm_id)
+		return;
+
+	cep->cm_id->rem_ref(cep->cm_id);
+	cep->cm_id = NULL;
+}
+
  /*
   * siw_qp_cm_drop()
   *
@@ -415,8 +424,7 @@ void siw_qp_cm_drop(struct siw_qp *qp, int schedule)
  			default:
  				break;
  			}
-			cep->cm_id->rem_ref(cep->cm_id);
-			cep->cm_id = NULL;
+			siw_free_cm_id(cep);
  			siw_cep_put(cep);
  		}
  		cep->state = SIW_EPSTATE_CLOSED;
@@ -1175,11 +1183,8 @@ static void siw_cm_work_handler(struct work_struct
*w)
  			sock_release(cep->sock);
  			cep->sock = NULL;
  		}
-		if (cep->cm_id) {
-			cep->cm_id->rem_ref(cep->cm_id);
-			cep->cm_id = NULL;
-			siw_cep_put(cep);
-		}
+		siw_free_cm_id(cep);
+		siw_cep_put(cep);
We must decrement the cep reference only if it had referenced
a cm_id. So here we need to put both into ' if (cep->cm_id) {'
clause again.

You are right, I somehow overlooked this ..

Thanks,
Guoqing



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux