diff mbox

[v2] RDMA/rxe: Simplify the error handling code in rxe_create_ah()

Message ID 20180706164532.10900-1-bart.vanassche@wdc.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show

Commit Message

Bart Van Assche July 6, 2018, 4:45 p.m. UTC
This patch not only simplifies the error handling code in rxe_create_ah()
but also removes the dead code that was left behind by commit 47ec38666210
("RDMA: Convert drivers to use sgid_attr instead of sgid_index").

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Parav Pandit <parav@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>
---

Changes compared to v1: implemented Parav's suggestion to change the "goto err1"
  statements into "return ERR_PTR()".

 drivers/infiniband/sw/rxe/rxe_verbs.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Comments

Parav Pandit July 6, 2018, 4:57 p.m. UTC | #1
Hi Bart,

> -----Original Message-----
> From: Bart Van Assche [mailto:bart.vanassche@wdc.com]
> Sent: Friday, July 06, 2018 11:46 AM
> To: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Doug Ledford <dledford@redhat.com>; linux-rdma@vger.kernel.org; Bart
> Van Assche <bart.vanassche@wdc.com>; Parav Pandit <parav@mellanox.com>;
> Leon Romanovsky <leonro@mellanox.com>
> Subject: [PATCH v2] RDMA/rxe: Simplify the error handling code in
> rxe_create_ah()
> 
> This patch not only simplifies the error handling code in rxe_create_ah() but also
> removes the dead code that was left behind by commit 47ec38666210
> ("RDMA: Convert drivers to use sgid_attr instead of sgid_index").
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Parav Pandit <parav@mellanox.com>
> Cc: Leon Romanovsky <leonro@mellanox.com>
> ---
> 
> Changes compared to v1: implemented Parav's suggestion to change the "goto
> err1"
>   statements into "return ERR_PTR()".
> 
>  drivers/infiniband/sw/rxe/rxe_verbs.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c
> b/drivers/infiniband/sw/rxe/rxe_verbs.c
> index 1272903d0fe3..0ea394554c8e 100644
> --- a/drivers/infiniband/sw/rxe/rxe_verbs.c
> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
> @@ -241,24 +241,17 @@ static struct ib_ah *rxe_create_ah(struct ib_pd *ibpd,
> 
>  	err = rxe_av_chk_attr(rxe, attr);
>  	if (err)
> -		goto err1;
> +		return ERR_PTR(err);
> 
>  	ah = rxe_alloc(&rxe->ah_pool);
> -	if (!ah) {
> -		err = -ENOMEM;
> -		goto err1;
> -	}
> +	if (!ah)
> +		return ERR_PTR(-ENOMEM);
> 
>  	rxe_add_ref(pd);
>  	ah->pd = pd;
> 
>  	rxe_init_av(rxe, attr, &ah->av);
>  	return &ah->ibah;
> -
> -	rxe_drop_ref(pd);
> -	rxe_drop_ref(ah);
> -err1:
> -	return ERR_PTR(err);
>  }
> 
>  static int rxe_modify_ah(struct ib_ah *ibah, struct rdma_ah_attr *attr)
> --
RB: parav@mellanox.com


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Leon Romanovsky July 8, 2018, 10:27 a.m. UTC | #2
On Fri, Jul 06, 2018 at 09:45:32AM -0700, Bart Van Assche wrote:
> This patch not only simplifies the error handling code in rxe_create_ah()
> but also removes the dead code that was left behind by commit 47ec38666210
> ("RDMA: Convert drivers to use sgid_attr instead of sgid_index").
>
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Parav Pandit <parav@mellanox.com>
> Cc: Leon Romanovsky <leonro@mellanox.com>
> ---
>
> Changes compared to v1: implemented Parav's suggestion to change the "goto err1"
>   statements into "return ERR_PTR()".
>
>  drivers/infiniband/sw/rxe/rxe_verbs.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
>

Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jason Gunthorpe July 9, 2018, 7:12 p.m. UTC | #3
On Fri, Jul 06, 2018 at 09:45:32AM -0700, Bart Van Assche wrote:
> This patch not only simplifies the error handling code in rxe_create_ah()
> but also removes the dead code that was left behind by commit 47ec38666210
> ("RDMA: Convert drivers to use sgid_attr instead of sgid_index").
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Parav Pandit <parav@mellanox.com>
> Cc: Leon Romanovsky <leonro@mellanox.com>
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> ---
> 
> Changes compared to v1: implemented Parav's suggestion to change the "goto err1"
>   statements into "return ERR_PTR()".

Applied to for-next

Thanks,
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index 1272903d0fe3..0ea394554c8e 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -241,24 +241,17 @@  static struct ib_ah *rxe_create_ah(struct ib_pd *ibpd,
 
 	err = rxe_av_chk_attr(rxe, attr);
 	if (err)
-		goto err1;
+		return ERR_PTR(err);
 
 	ah = rxe_alloc(&rxe->ah_pool);
-	if (!ah) {
-		err = -ENOMEM;
-		goto err1;
-	}
+	if (!ah)
+		return ERR_PTR(-ENOMEM);
 
 	rxe_add_ref(pd);
 	ah->pd = pd;
 
 	rxe_init_av(rxe, attr, &ah->av);
 	return &ah->ibah;
-
-	rxe_drop_ref(pd);
-	rxe_drop_ref(ah);
-err1:
-	return ERR_PTR(err);
 }
 
 static int rxe_modify_ah(struct ib_ah *ibah, struct rdma_ah_attr *attr)