Skip to content

Commit c290fba

Browse files
JunPiaoHWtorvalds
authored andcommitted
net/9p/client.c: put refcount of trans_mod in error case in parse_opts()
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/[email protected] Fixes: 9421c3e ("net/9p/client.c: fix potential refcnt problem of trans module") Signed-off-by: Jun Piao <[email protected]> Reviewed-by: Yiwen Jiang <[email protected]> Reviewed-by: Greg Kurz <[email protected]> Reviewed-by: Dominique Martinet <[email protected]> Tested-by: Dominique Martinet <[email protected]> Cc: Eric Van Hensbergen <[email protected]> Cc: Ron Minnich <[email protected]> Cc: Latchesar Ionkov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent a90744b commit c290fba

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/9p/client.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ static int parse_opts(char *opts, struct p9_client *clnt)
225225
}
226226

227227
free_and_return:
228-
v9fs_put_trans(clnt->trans_mod);
228+
if (ret)
229+
v9fs_put_trans(clnt->trans_mod);
229230
kfree(tmp_options);
230231
return ret;
231232
}

0 commit comments

Comments
 (0)