Commit a25c3657 authored by Chengguang Xu's avatar Chengguang Xu Committed by Linus Torvalds

9p: check memory allocation result for cachetag

Check memory allocation result for cachetag in mount option parsing and
fix potential memory leak in the error case.

Link: http://lkml.kernel.org/r/1521614889-73446-1-git-send-email-cgxu519@gmx.comSigned-off-by: default avatarChengguang Xu <cgxu519@gmx.com>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ron Minnich <rminnich@sandia.gov>
Cc: Latchesar Ionkov <lucho@ionkov.net>
Cc: <v9fs-developer@lists.sourceforge.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ac89b2ef
...@@ -292,6 +292,10 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) ...@@ -292,6 +292,10 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
#ifdef CONFIG_9P_FSCACHE #ifdef CONFIG_9P_FSCACHE
kfree(v9ses->cachetag); kfree(v9ses->cachetag);
v9ses->cachetag = match_strdup(&args[0]); v9ses->cachetag = match_strdup(&args[0]);
if (!v9ses->cachetag) {
ret = -ENOMEM;
goto free_and_return;
}
#endif #endif
break; break;
case Opt_cache: case Opt_cache:
...@@ -471,6 +475,9 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses, ...@@ -471,6 +475,9 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
return fid; return fid;
err_clnt: err_clnt:
#ifdef CONFIG_9P_FSCACHE
kfree(v9ses->cachetag);
#endif
p9_client_destroy(v9ses->clnt); p9_client_destroy(v9ses->clnt);
err_names: err_names:
kfree(v9ses->uname); kfree(v9ses->uname);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment