Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp685315imm; Mon, 9 Jul 2018 08:50:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcQDfhQJZz1NCcDxWkinYgbFiIN0hSXx8mvIkCpN+Qgk55pitCHOfZUgjUTtGNPWbDybwKL X-Received: by 2002:a65:64cf:: with SMTP id t15-v6mr19193982pgv.79.1531151420221; Mon, 09 Jul 2018 08:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531151420; cv=none; d=google.com; s=arc-20160816; b=SkFtNjEl23YVlsdrpzWiINTAuPf+NPXb5eGsqam2JoNUUuegKZGR5lH76tyBoB3YoP oFfZ9KsstKjC+E8X8GlYiAkmDwAebBwC6rGWbz72EHtIExPY6Lo5ngGmQwhS3gq3co6I tvRr+YhsA7FUtYdOJ+CBY9geUSK3Aeu+UzXs7GarSJ8sIxXyklG+1TZDbg14LS8IL1P9 /1oz9jBVU+KfUP2qak00lOe8LgNJ0CRFFunXft8pDew45HJeiBVogcZLf/TLZXLT0HDO EoqhQCG1RzG/omJ2EpEVyRGRP335HN8yd59LOi7QLRGyhMRc76SJWVcJqgPYcygebNat hhyA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=zVC20hrPzArU4uwcUWFXHcPI22nOiTcAD7HG0Xc0ln8=; b=YYMOfWuK5NZz1Wi05esZ5jxdWgbf9UiylU+GStFTRjRGMlnZJfTYxazGwzTnmsFYTg AdAGbjNsHLODzKbmATWTJo0J9C/q9S6U7jFrGVtOpGrhEHg+hPNqfnnuvXlZVuZUHay2 ZNwsLTL4/AxupUo6ASoIIcHJdNWyH0aEnYSJTDe9nbzhePXJqCBru/tq1A3uAKlonJhY O1Gi4CGIKbMMTLV8zfnDkSk5jWzA5dfeEBQsRAybyoxumAIKiu7twUFwWX/yElmPfLL+ 1IRTtc63hhXlHqUsIftcB+t3kZ6jc7w7ZtdH4jfuVTWzRpm0G2wtV+4RRpjCLOoIMmwO NPKQ== 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 b10-v6si14109655pls.501.2018.07.09.08.50.04; Mon, 09 Jul 2018 08:50:20 -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 S933411AbeGIPtF (ORCPT + 99 others); Mon, 9 Jul 2018 11:49:05 -0400 Received: from 7.mo177.mail-out.ovh.net ([46.105.61.149]:39972 "EHLO 7.mo177.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932686AbeGIPtD (ORCPT ); Mon, 9 Jul 2018 11:49:03 -0400 X-Greylist: delayed 4200 seconds by postgrey-1.27 at vger.kernel.org; Mon, 09 Jul 2018 11:49:03 EDT Received: from player715.ha.ovh.net (unknown [10.109.122.33]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id 82814B757B for ; Mon, 9 Jul 2018 16:29:31 +0200 (CEST) Received: from bahia.lan (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player715.ha.ovh.net (Postfix) with ESMTPSA id AA9581C00E8; Mon, 9 Jul 2018 16:29:21 +0200 (CEST) Date: Mon, 9 Jul 2018 16:29:20 +0200 From: Greg Kurz To: piaojun Cc: "akpm@linux-foundation.org" , , , , v9fs-developer@lists.sourceforge.net, Linux Kernel Mailing List Subject: Re: [V9fs-developer] [PATCH] net/9p/client.c: put refcount of trans_mod in error case in parse_opts() Message-ID: <20180709162920.2b94916f@bahia.lan> In-Reply-To: <5B3F39A0.2030509@huawei.com> References: <5B3F39A0.2030509@huawei.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Ovh-Tracer-Id: 8163618751270197734 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtiedrgedvgdejkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 6 Jul 2018 17:42:56 +0800 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 > --- Reviewed-by: Greg Kurz > 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; > }