Skip to content

Commit

Permalink
net/9p/client.c: put refcount of trans_mod in error case in parse_opts()
Browse files Browse the repository at this point in the history
In my testing, 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.

Link: http://lkml.kernel.org/r/5B3F39A0.2030509@huawei.com
Fixes: 9421c3e ("net/9p/client.c: fix potential refcnt problem of trans module")
Signed-off-by: Jun Piao <piaojun@huawei.com>
Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Dominique Martinet <dominique.martinet@cea.fr>
Tested-by: Dominique Martinet <dominique.martinet@cea.fr>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ron Minnich <rminnich@sandia.gov>
Cc: Latchesar Ionkov <lucho@ionkov.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
JunPiaoHW authored and torvalds committed Jul 14, 2018
1 parent a90744b commit c290fba
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/9p/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c290fba

Please sign in to comment.