Skip to contentSkip to conversation

RDMA/ucma: Cleanup to reduce duplicate code

PATCH Applied Xiaofei Tan 3 participants 3 messages May 6, 2021 – May 11, 2021 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/ucma: Cleanup to reduce duplicate code

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.

---
 drivers/infiniband/core/ucma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/core/ucma.c +2 -2
index 15d57ba..1f198c1 100644
@@ -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);
Signature · 1 line
2.8.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Xiaofei Tan

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.

---
 drivers/infiniband/core/ucma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Thanks,

maintainer Applied
#2 lore raw
In reply to Xiaofei Tan
Quoted 9 lines · Xiaofei Tan

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.

---
 drivers/infiniband/core/ucma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied to for-next, thanks

Jason