diff mbox series

RDMA/ucma: Cleanup to reduce duplicate code

Message ID 1620291106-3675-1-git-send-email-tanxiaofei@huawei.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series RDMA/ucma: Cleanup to reduce duplicate code | expand

Commit Message

Xiaofei Tan May 6, 2021, 8:51 a.m. UTC
The lable "err1" does the same thing as the branch of copy_to_user()
failed in the function ucma_create_id(). Just jump to the label directly
to reduce duplicate code.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
---
 drivers/infiniband/core/ucma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Leon Romanovsky May 6, 2021, 9:04 a.m. UTC | #1
On Thu, May 06, 2021 at 04:51:46PM +0800, Xiaofei Tan wrote:
> The lable "err1" does the same thing as the branch of copy_to_user()
> failed in the function ucma_create_id(). Just jump to the label directly
> to reduce duplicate code.
> 
> Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
> ---
>  drivers/infiniband/core/ucma.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Jason Gunthorpe May 11, 2021, 7:37 p.m. UTC | #2
On Thu, May 06, 2021 at 04:51:46PM +0800, Xiaofei Tan wrote:
> The lable "err1" does the same thing as the branch of copy_to_user()
> failed in the function ucma_create_id(). Just jump to the label directly
> to reduce duplicate code.
> 
> Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>  drivers/infiniband/core/ucma.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied to for-next, thanks

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 15d57ba..1f198c1 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -468,8 +468,8 @@  static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf,
 	resp.id = ctx->id;
 	if (copy_to_user(u64_to_user_ptr(cmd.response),
 			 &resp, sizeof(resp))) {
-		ucma_destroy_private_ctx(ctx);
-		return -EFAULT;
+		ret = -EFAULT;
+		goto err1;
 	}
 
 	mutex_lock(&file->mut);