Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1169188pxy; Thu, 6 May 2021 01:56:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlYhxpTReswfnAsr36sDgCgwIlzTKRGfRJvLLdLpUpnlHlO+vUYPldEjxgy0AiGJbZ5Rpr X-Received: by 2002:a17:906:d9dc:: with SMTP id qk28mr3171808ejb.497.1620291409304; Thu, 06 May 2021 01:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620291409; cv=none; d=google.com; s=arc-20160816; b=TneVfwNRgYhSsi5SRTPcnnoLLuRAEsJ5Eu7uaBeO+fpD6o5Yo/V/4hJooUbD2q4RZr HTzfzmL+/DDA4OjmZSl4FNs/4IFigCY04fyJtYawBCqlWKRtUZ8tSQzlnNLCeegdenRH nPx+rVctiN7OmZro94hmAydC7m3xRBeHYU/wwo5Cafvt9n/0F1yW/UdwKED8Riu2nOh7 R7P+bMlbK7VPTixaJ/AcLs5o3HWBT1+1ZvEuFSb+Dc026w7dQviQMbAlmfW1U3QbkbI5 Zt9SNxZQF15hIKzEQ1jQwAUK57BI+auQ5xsvlQzdR+/19GBpZYHDkMqpl8Ayt3gYl1sB wlXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=Iwxil7NHI4wh42+DJgRgL45LxywYZd1k5fAcSs++OR0=; b=jb7WddIFXugYm2IahiFnds6pePpFbozhOY9AHlBtnLZJPgbuSoyD5Zhwd/NxhfNBL9 amIuTmbXaHsJMCy+z3Jw8rg0XV27BFNcMeZg2kiT1TmqwBETsYrPnmbIoHQbZTzuqo9e Uc+CmWAgKAqjwXT0Z2zwFfcO3M34QbuduQ8mwlzGEwhpkIehsxV6pnYH+QqUbGmhXeFH 6VFR2/R6A+9GS6HjtdDtuJg+cB9HQoQut783S8tzpN9OILRx4FbEzAXK2MWhN1Cu6+B/ cwoGXjpsQH69fO1CVDSFZFiw4iUpUmjv24Muh2WUPiCuoYJ7UTe6yRPceuMHrkPsh5Ef r8Ow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x11si1763721ejv.267.2021.05.06.01.56.24; Thu, 06 May 2021 01:56:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233944AbhEFIzp (ORCPT + 99 others); Thu, 6 May 2021 04:55:45 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:17472 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233852AbhEFIzp (ORCPT ); Thu, 6 May 2021 04:55:45 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FbS4p5zYSzkWrH; Thu, 6 May 2021 16:52:10 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Thu, 6 May 2021 16:54:39 +0800 From: Xiaofei Tan To: , CC: , , , , , , Xiaofei Tan Subject: [PATCH] RDMA/ucma: Cleanup to reduce duplicate code Date: Thu, 6 May 2021 16:51:46 +0800 Message-ID: <1620291106-3675-1-git-send-email-tanxiaofei@huawei.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/infiniband/core/ucma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); -- 2.8.1