Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1584159imm; Fri, 6 Jul 2018 02:49:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdfJdNPsyW7zdQjpxeQFpu0hAvEOTRJCKLNLUxlAOrdoiRnd9h39QO4OMrDpF2VrKULp4FZ X-Received: by 2002:a17:902:b589:: with SMTP id a9-v6mr9705764pls.140.1530870566738; Fri, 06 Jul 2018 02:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530870566; cv=none; d=google.com; s=arc-20160816; b=RRP15CWKu5n7ELBxLFc2ZSXRSpdVVwiAD53sDeOG3VQ40SiYJPzfHuQjPD4gZDuNW+ xtlHfwZmZFsJla0LuCxJB+rxSFS//Smj7twqJ9myBhUyTmfTDBFW+qh8vbXbtpJbEakT AQvcuQUJzSOyRAKetpLCIg+7TtwuTx6tsaCWDtWvcCamyNbmVwtpq2Ik7ZTxtiOnGbxo PmlXo6QYWDD0mwZTjA60R/3nY8pFCa0nGFMKfeKIz9sIiO5B4O2mig4ra0JhLMX3qO9O g0shcwrmpSQzL3xL8EXbPLGnYICWvvg3bJZ/SIXiU5WAbXN1O9yFbCET7chG7StDvacE t1gg== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=rLLi9WLqg8JBDBknT5ny6Vb+uch7gvvnYlX5KJ7RZq4=; b=DqZJgAMce+VaalF+67fhmagnQVmyXUphYrW1CrONvLEd+HXRKMrarfGHLCTM9ODAIx cT3aZXP18jOLl9vqpCMQZEo21IDFP2cQsR4M8pGukExN9pUpcgMPeoUaPIywHmj5IVpa pWkbqvMywmdZazQo7J9IykD1hyTFfgzAvg9xzJxLHvfBPGVJgn5HVT06sa5IKH11rC7y Lz6kiR3cKYvLIqAEK5XbbvI06UFOxUyMaMzhv68DTwgDd+KadPGjjIzo87qLKkHFwE7A GSzvPYX6aArhhlu/Wr53PQhiwCet9L9fgoIg+Odj8/NG2ut6esGPKvYx3B6x3KUJ5DE5 nV0g== 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.49.11; Fri, 06 Jul 2018 02:49:26 -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 S1753704AbeGFJsS (ORCPT + 99 others); Fri, 6 Jul 2018 05:48:18 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51815 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753367AbeGFJsQ (ORCPT ); Fri, 6 Jul 2018 05:48:16 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2CAA6BE80DEBD; Fri, 6 Jul 2018 17:48:13 +0800 (CST) Received: from [127.0.0.1] (10.177.16.168) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.382.0; Fri, 6 Jul 2018 17:48:04 +0800 Subject: Re: [PATCH] net/9p/client.c: put refcount of trans_mod in error case in parse_opts() To: piaojun , "akpm@linux-foundation.org" , , , References: <5B3F39A0.2030509@huawei.com> CC: Linux Kernel Mailing List , From: jiangyiwen Message-ID: <5B3F3AD1.9010101@huawei.com> Date: Fri, 6 Jul 2018 17:48:01 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <5B3F39A0.2030509@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.16.168] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/7/6 17:42, piaojun wrote: >>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 It looks good to me. Reviewed-by: Yiwen Jiang > --- > 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; > } >