From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chengguang Xu Subject: [PATCH] net/9p: fix potential refcnt problem of trans module Date: Tue, 27 Mar 2018 20:49:02 +0800 Message-ID: <1522154942-57339-1-git-send-email-cgxu519@gmx.com> Cc: v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org, Chengguang Xu To: ericvh@gmail.com, rminnich@sandia.gov, lucho@ionkov.net, davem@davemloft.net Return-path: Received: from mout.gmx.net ([212.227.17.22]:41943 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750914AbeC0Mtv (ORCPT ); Tue, 27 Mar 2018 08:49:51 -0400 Sender: netdev-owner@vger.kernel.org List-ID: When specifying trans_mod multiple times in a mount, it may cause inaccurate refcount of trans module. Also, in the error case of option parsing, we should put the trans module if we have already got. Signed-off-by: Chengguang Xu --- net/9p/client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/9p/client.c b/net/9p/client.c index b433aff..7ccfb4b 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -190,7 +190,9 @@ static int parse_opts(char *opts, struct p9_client *clnt) p9_debug(P9_DEBUG_ERROR, "problem allocating copy of trans arg\n"); goto free_and_return; - } + } + + v9fs_put_trans(clnt->trans_mod); clnt->trans_mod = v9fs_get_trans_by_name(s); if (clnt->trans_mod == NULL) { pr_info("Could not find request transport: %s\n", @@ -226,6 +228,7 @@ static int parse_opts(char *opts, struct p9_client *clnt) } free_and_return: + v9fs_put_trans(clnt->trans_mod); kfree(tmp_options); return ret; } -- 1.8.3.1