Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1469969ybz; Wed, 29 Apr 2020 23:17:52 -0700 (PDT) X-Google-Smtp-Source: APiQypJbUulk6boU3hBRCDUeunF9u7ZJ1TEPObdu3bUjgA23z22lo+XaTmldZkGsWycRsIoeEmo7 X-Received: by 2002:a05:6402:1757:: with SMTP id v23mr1264386edx.335.1588227472721; Wed, 29 Apr 2020 23:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588227472; cv=none; d=google.com; s=arc-20160816; b=GJxvLcrncjHMZZSiwIPYssveUn00k/651IuO101FoVB3uoqLCRYp7MfjaKjiGSF7sb mvZ6m0YOb3Z/BLOVkR9Jj1PAeqjipzVfbGFcD7xDJH23FnfNh3tki7sdlcsjQQNRlvmM BUvtCgfD76bo47RhPfsvHGmpMYAy0dB9xuEdR3XffiiUFn0HnCM6YxEmCHlT3kn8mxDD AMImTV/NIJJ0X0qdE+dhvN5fxXMHp1tIof6nVkg0gqrsKD5eh1yOfaWe5pK4wpORV/Jr 9TQM4lfF6nXAFh8CCg1ogqtWQOcT+fbg4OPQMHPdtJf//ikltH7FaIWnH8t4LQB4k8BV zOcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=FppFOIaDroG9XxiVeYN4i7+IrdlhcQglWHWbxcUw/h0=; b=MT2L4Jz5aN11DN8wsC5EkQ9jtMm3fFr4BtOFf9BnZMWjgyJGYu5GG8nk5N6ImSNpNU IxCLdGDKo7eKVi2QpSO/GoI1CdED63TyLVgPT64DXJF7g1/NC5gCi92kwBlfzJdLzw6A bfhgr5/6UMxnuA5pxSfQY65uAeYU4GCs8ovLqxA2RAxRo2WB7BcM0Te8EeLbBSfKsOjk uOH2KVntFOR/A5K3wsxlZ5NLRoaTFqkpGhllwdagyB1cP60Pkm7EaoUNytfzRe/2A14n wKmcjl4rKTwQiLtQkoNLi9uhrIy/rgtqeTrr6LRYR9NDL2dQrD44xJDiwLHXXoMNxL6E qc8A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bd6si3930976edb.277.2020.04.29.23.17.28; Wed, 29 Apr 2020 23:17:52 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbgD3GN6 (ORCPT + 99 others); Thu, 30 Apr 2020 02:13:58 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:47542 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726378AbgD3GN6 (ORCPT ); Thu, 30 Apr 2020 02:13:58 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A3665E8AE37DF678951F; Thu, 30 Apr 2020 14:13:54 +0800 (CST) Received: from huawei.com (10.175.105.27) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Thu, 30 Apr 2020 14:13:47 +0800 From: Wu Bo To: , , , CC: , , , , Subject: [PATCH V3] fs/ceph:fix double unlock in handle_cap_export() Date: Thu, 30 Apr 2020 14:12:49 +0800 Message-ID: <1588227169-83237-1-git-send-email-wubo40@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.105.27] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the ceph_mdsc_open_export_target_session() return fails, we should add mutex_lock(&session->s_mutex) on IS_ERR(tsession) block to avoid twice unlocking. because the session->s_mutex will be unlock at the out_unlock lable. -- v2 -> v3: - Rewrite solution, adding a mutex_lock(&session->s_mutex) to the IS_ERR(tsession) block. - Modify the comment more clearly. v1 -> v2: - add spin_lock(&ci->i_ceph_lock) before goto out_unlock lable Signed-off-by: Wu Bo --- fs/ceph/caps.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 185db76..d27d778 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -3746,6 +3746,7 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex, WARN_ON(1); tsession = NULL; target = -1; + mutex_lock(&session->s_mutex); } goto retry; -- 1.8.3.1