diff mbox series

[V2,19/20] RDMA/siw: Introduce siw_destroy_cep_sock

Message ID 20231013020053.2120-20-guoqing.jiang@linux.dev (mailing list archive)
State Superseded
Headers show
Series Cleanup for siw | expand

Commit Message

Guoqing Jiang Oct. 13, 2023, 2 a.m. UTC
Add one helper to simplify code a bit.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202310091735.oG7bTvLR-lkp@intel.com/`
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
---
 drivers/infiniband/sw/siw/siw_cm.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

Comments

Bernard Metzler Oct. 25, 2023, 1:28 p.m. UTC | #1
> -----Original Message-----
> From: Guoqing Jiang <guoqing.jiang@linux.dev>
> Sent: Friday, October 13, 2023 4:01 AM
> To: Bernard Metzler <BMT@zurich.ibm.com>; jgg@ziepe.ca; leon@kernel.org
> Cc: linux-rdma@vger.kernel.org
> Subject: [EXTERNAL] [PATCH V2 19/20] RDMA/siw: Introduce
> siw_destroy_cep_sock
> 
> Add one helper to simplify code a bit.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: INVALID URI REMOVED
> 3A__lore.kernel.org_oe-2Dkbuild-2Dall_202310091735.oG7bTvLR-2Dlkp-
> 40intel.com_&d=DwIDAg&c=jf_iaSHvJObTbx-siA1ZOg&r=2TaYXQ0T-
> r8ZO1PP1alNwU_QJcRRLfmYTAgd3QCvqSc&m=glgYr0ZTX68mQQ5KqLKVgtMwCeBUa2g6CMcsI-
> atXWhya5f5qFEHlXxYa8pfeW7n&s=1mAM2DAKVpNKr6zJQofHUOMQ7rXtPvPUmZDLwpNySZ4&e=
> `
> Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
> ---
>  drivers/infiniband/sw/siw/siw_cm.c | 26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/infiniband/sw/siw/siw_cm.c
> b/drivers/infiniband/sw/siw/siw_cm.c
> index be0d09d18a4f..4b3fde6ca9ca 100644
> --- a/drivers/infiniband/sw/siw/siw_cm.c
> +++ b/drivers/infiniband/sw/siw/siw_cm.c
> @@ -368,6 +368,15 @@ static void siw_free_cm_id(struct siw_cep *cep, bool
> put_cep)
>  		siw_cep_put(cep);
>  }
> 
> +static void siw_destroy_cep_sock(struct siw_cep *cep)
> +{
> +	if (cep->sock) {
> +		siw_socket_disassoc(cep->sock);
> +		sock_release(cep->sock);
> +		cep->sock = NULL;
> +	}
> +}
> +
>  /*
>   * siw_qp_cm_drop()
>   *
> @@ -423,14 +432,7 @@ void siw_qp_cm_drop(struct siw_qp *qp, int schedule)
>  		}
>  		cep->state = SIW_EPSTATE_CLOSED;
> 
> -		if (cep->sock) {
> -			siw_socket_disassoc(cep->sock);
> -			/*
> -			 * Immediately close socket
> -			 */
> -			sock_release(cep->sock);
> -			cep->sock = NULL;
> -		}
> +		siw_destroy_cep_sock(cep);
>  		if (cep->qp) {
>  			cep->qp = NULL;
>  			siw_qp_put(qp);
> @@ -1682,9 +1684,7 @@ int siw_accept(struct iw_cm_id *id, struct
> iw_cm_conn_param *params)
>  error_unlock:
>  	up_write(&qp->state_lock);
>  error:
> -	siw_socket_disassoc(cep->sock);
> -	sock_release(cep->sock);
> -	cep->sock = NULL;
> +	siw_destroy_cep_sock(cep);
> 
>  	cep->state = SIW_EPSTATE_CLOSED;
> 
> @@ -1729,9 +1729,7 @@ int siw_reject(struct iw_cm_id *id, const void
> *pdata, u8 pd_len)
>  		cep->mpa.hdr.params.bits |= MPA_RR_FLAG_REJECT; /* reject */
>  		siw_send_mpareqrep(cep, pdata, pd_len);
>  	}
> -	siw_socket_disassoc(cep->sock);
> -	sock_release(cep->sock);
> -	cep->sock = NULL;
> +	siw_destroy_cep_sock(cep);
> 
>  	cep->state = SIW_EPSTATE_CLOSED;
> 
> --
> 2.35.3

OK

Acked-by: Bernard Metzler <bmt@zurich.ibm.com>
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c
index be0d09d18a4f..4b3fde6ca9ca 100644
--- a/drivers/infiniband/sw/siw/siw_cm.c
+++ b/drivers/infiniband/sw/siw/siw_cm.c
@@ -368,6 +368,15 @@  static void siw_free_cm_id(struct siw_cep *cep, bool put_cep)
 		siw_cep_put(cep);
 }
 
+static void siw_destroy_cep_sock(struct siw_cep *cep)
+{
+	if (cep->sock) {
+		siw_socket_disassoc(cep->sock);
+		sock_release(cep->sock);
+		cep->sock = NULL;
+	}
+}
+
 /*
  * siw_qp_cm_drop()
  *
@@ -423,14 +432,7 @@  void siw_qp_cm_drop(struct siw_qp *qp, int schedule)
 		}
 		cep->state = SIW_EPSTATE_CLOSED;
 
-		if (cep->sock) {
-			siw_socket_disassoc(cep->sock);
-			/*
-			 * Immediately close socket
-			 */
-			sock_release(cep->sock);
-			cep->sock = NULL;
-		}
+		siw_destroy_cep_sock(cep);
 		if (cep->qp) {
 			cep->qp = NULL;
 			siw_qp_put(qp);
@@ -1682,9 +1684,7 @@  int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params)
 error_unlock:
 	up_write(&qp->state_lock);
 error:
-	siw_socket_disassoc(cep->sock);
-	sock_release(cep->sock);
-	cep->sock = NULL;
+	siw_destroy_cep_sock(cep);
 
 	cep->state = SIW_EPSTATE_CLOSED;
 
@@ -1729,9 +1729,7 @@  int siw_reject(struct iw_cm_id *id, const void *pdata, u8 pd_len)
 		cep->mpa.hdr.params.bits |= MPA_RR_FLAG_REJECT; /* reject */
 		siw_send_mpareqrep(cep, pdata, pd_len);
 	}
-	siw_socket_disassoc(cep->sock);
-	sock_release(cep->sock);
-	cep->sock = NULL;
+	siw_destroy_cep_sock(cep);
 
 	cep->state = SIW_EPSTATE_CLOSED;