Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1580514imm; Fri, 6 Jul 2018 02:44:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdSboVYZKN6i0Hy/c2ll++GSyOUDWKOIFUcyGWFp2NY5GnC8fczzMoL4IgMF6eQSuRbYX8Z X-Received: by 2002:a63:7c18:: with SMTP id x24-v6mr8830120pgc.311.1530870274951; Fri, 06 Jul 2018 02:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530870274; cv=none; d=google.com; s=arc-20160816; b=0UUibhZisCc5FCWzGKRH50jxvMNuAPpreIfE8wx2i2lk4qPdz5C3WRobKEznichm2W QI83sOGclH7JNgQLiNA7LpDhgaplP1sHVczbUomc7yJ2eg4+BnHUE43giA5jPRm/y2Yd p0XQuFRisYelwFH8XrnuPzkPwauKNtk6nFSlL1EjdpkA6Atq51gfF2+SHK9wH1ZrSemu S6224eTxY+NRmI2/Y3QcXB++lFbE2w0mPRoDN98pRbJY0NB3LmfRPKBPortXz8Y1H1EB GwNrBOvRKBRVn5vvmZ1bc+/dIF0Mwaj+MyWc5b9syBoklGMYVOqi7pgKaSTXCkIfsuth Enkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:date:message-id:subject:from:cc:to :arc-authentication-results; bh=7FYuWsplUd5llTLvYB1e3Btaw+4D8LdtSVjjBtzOLtk=; b=q/pA8zKDWuC/6KDEL/qV8sC9heHHGzLZ2yAQvPUDT+SZ1ij72u7VhpaCMkPPK9quMq Jenwc24VESLsg5hhJ/RHBClDTtvwfdIoPNoWvrJ71RvB4dH1GsWwHBKUIiHdebiRXrP8 hzjvTwu+3DAdvQs5F8JeEdufM/RgyrVjQUHjEc5baR9B1CPk9XtNyuTtao0n6Rs2kran 8LQOyayPsMsmiykapFFEoj5ShKHmzmIfs6wz+N5DiXEgG3j9Lr4FmXgxL/J+aqhRdwzT RtaFvXwhZmhId2Y2RzVpv5F59843DqdttNNkpJT0JAwKL2CJNOIOFPTxAaipAov78t9v AbfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7-v6si7797053plt.149.2018.07.06.02.44.20; Fri, 06 Jul 2018 02:44:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753804AbeGFJng (ORCPT + 99 others); Fri, 6 Jul 2018 05:43:36 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9206 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753732AbeGFJnd (ORCPT ); Fri, 6 Jul 2018 05:43:33 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7AA51DDAC82E0; Fri, 6 Jul 2018 17:43:19 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Fri, 6 Jul 2018 17:43:14 +0800 To: "akpm@linux-foundation.org" , , , CC: Linux Kernel Mailing List , , Jiangyiwen From: piaojun Subject: [PATCH] net/9p/client.c: put refcount of trans_mod in error case in parse_opts() Message-ID: <5B3F39A0.2030509@huawei.com> Date: Fri, 6 Jul 2018 17:42:56 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From my test, the second mount will fail after umounting successfully. The reason is that we put refcount of trans_mod in the correct case rather than the error case in parse_opts() at last. That will cause the refcount decrease to -1, and when we try to get trans_mod again in try_module_get(), we could only increase refcount to 0 which will cause failure as follows: parse_opts v9fs_get_trans_by_name try_module_get : return NULL to caller which cause error So we should put refcount of trans_mod in error case. Fixes: 9421c3e64137ec ("net/9p/client.c: fix potential refcnt problem of trans module") Signed-off-by: Jun Piao --- net/9p/client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/9p/client.c b/net/9p/client.c index 18c5271..5c13431 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -225,7 +225,8 @@ static int parse_opts(char *opts, struct p9_client *clnt) } free_and_return: - v9fs_put_trans(clnt->trans_mod); + if (ret) + v9fs_put_trans(clnt->trans_mod); kfree(tmp_options); return ret; } --