linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guoqing Jiang <guoqing.jiang@linux.dev>
To: bmt@zurich.ibm.com, jgg@ziepe.ca, leon@kernel.org
Cc: linux-rdma@vger.kernel.org
Subject: [PATCH V3 12/18] RDMA/siw: Introduce siw_free_cm_id
Date: Fri, 27 Oct 2023 10:33:22 +0800	[thread overview]
Message-ID: <20231027023328.30347-13-guoqing.jiang@linux.dev> (raw)
In-Reply-To: <20231027023328.30347-1-guoqing.jiang@linux.dev>

Factor out a helper to simplify code.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202310091656.JlrmcNXB-lkp@intel.com/
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
---
 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);
 	}
 	siw_cep_set_free(cep);
 	siw_put_work(work);
@@ -1702,10 +1707,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params)
 
 	cep->state = SIW_EPSTATE_CLOSED;
 
-	if (cep->cm_id) {
-		cep->cm_id->rem_ref(id);
-		cep->cm_id = NULL;
-	}
+	siw_free_cm_id(cep);
 	if (qp->cep) {
 		siw_cep_put(cep);
 		qp->cep = NULL;
@@ -1880,10 +1882,7 @@ int siw_create_listen(struct iw_cm_id *id, int backlog)
 	if (cep) {
 		siw_cep_set_inuse(cep);
 
-		if (cep->cm_id) {
-			cep->cm_id->rem_ref(cep->cm_id);
-			cep->cm_id = NULL;
-		}
+		siw_free_cm_id(cep);
 		cep->sock = NULL;
 		siw_socket_disassoc(s);
 		cep->state = SIW_EPSTATE_CLOSED;
@@ -1912,10 +1911,7 @@ static void siw_drop_listeners(struct iw_cm_id *id)
 
 		siw_cep_set_inuse(cep);
 
-		if (cep->cm_id) {
-			cep->cm_id->rem_ref(cep->cm_id);
-			cep->cm_id = NULL;
-		}
+		siw_free_cm_id(cep);
 		if (cep->sock) {
 			siw_socket_disassoc(cep->sock);
 			sock_release(cep->sock);
-- 
2.35.3


  parent reply	other threads:[~2023-10-27  2:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-27  2:33 [PATCH V3 00/18] Cleanup for siw Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 01/18] RDMA/siw: Introduce siw_get_page Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 02/18] RDMA/siw: Introduce siw_update_skb_rcvd Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 03/18] RDMA/siw: Use iov.iov_len in kernel_sendmsg Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 04/18] RDMA/siw: Remove goto lable in siw_mmap Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 05/18] RDMA/siw: Remove rcu from siw_qp Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 06/18] RDMA/siw: No need to check term_info.valid before call siw_send_terminate Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 07/18] RDMA/siw: Also goto out_sem_up if pin_user_pages returns 0 Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 08/18] RDMA/siw: Factor out siw_generic_rx helper Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 09/18] RDMA/siw: Introduce SIW_STAG_MAX_INDEX Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 10/18] RDMA/siw: Add one parameter to siw_destroy_cpulist Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 11/18] RDMA/siw: Introduce siw_cep_set_free_and_put Guoqing Jiang
2023-10-27  2:33 ` Guoqing Jiang [this message]
2023-10-27  2:33 ` [PATCH V3 13/18] RDMA/siw: Cleanup siw_accept Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 14/18] RDMA/siw: Remove siw_sk_save_upcalls Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 15/18] RDMA/siw: Fix typo Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 16/18] RDMA/siw: Only check attrs->cap.max_send_wr in siw_create_qp Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 17/18] RDMA/siw: Introduce siw_destroy_cep_sock Guoqing Jiang
2023-10-27  2:33 ` [PATCH V3 18/18] RDMA/siw: Update comments for siw_qp_sq_process Guoqing Jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231027023328.30347-13-guoqing.jiang@linux.dev \
    --to=guoqing.jiang@linux.dev \
    --cc=bmt@zurich.ibm.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).