All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: piaojun <piaojun@huawei.com>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	<ericvh@gmail.com>, <rminnich@sandia.gov>, <lucho@ionkov.net>,
	v9fs-developer@lists.sourceforge.net,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [V9fs-developer] [PATCH] net/9p/client.c: put refcount of trans_mod in error case in parse_opts()
Date: Mon, 9 Jul 2018 16:29:20 +0200	[thread overview]
Message-ID: <20180709162920.2b94916f@bahia.lan> (raw)
In-Reply-To: <5B3F39A0.2030509@huawei.com>

On Fri, 6 Jul 2018 17:42:56 +0800
piaojun <piaojun@huawei.com> 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 <piaojun@huawei.com>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  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;
>  }


  parent reply	other threads:[~2018-07-09 15:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-06  9:42 [PATCH] net/9p/client.c: put refcount of trans_mod in error case in parse_opts() piaojun
2018-07-06  9:48 ` jiangyiwen
2018-07-09 14:29 ` Greg Kurz [this message]
2018-07-11  5:47 ` [V9fs-developer] " Dominique Martinet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180709162920.2b94916f@bahia.lan \
    --to=groug@kaod.org \
    --cc=akpm@linux-foundation.org \
    --cc=ericvh@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=piaojun@huawei.com \
    --cc=rminnich@sandia.gov \
    --cc=v9fs-developer@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.