diff options
author | Chengguang Xu <cgxu519@gmx.com> | 2018-04-05 19:19:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-06 00:36:22 -0400 |
commit | a25c36577ca788f9ea4b229baef1b6d436393a4c (patch) | |
tree | 8300b3cc58689b5624da6b25f2bd5ed052a1a71b | |
parent | ac89b2ef9b55924bcf922251f043ba73a32d05bb (diff) |
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.com
Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
Reviewed-by: Andrew 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/9p/v9fs.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 8fb89ddc6cc7..e622f0f10502 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c | |||
@@ -292,6 +292,10 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
292 | #ifdef CONFIG_9P_FSCACHE | 292 | #ifdef CONFIG_9P_FSCACHE |
293 | kfree(v9ses->cachetag); | 293 | kfree(v9ses->cachetag); |
294 | v9ses->cachetag = match_strdup(&args[0]); | 294 | v9ses->cachetag = match_strdup(&args[0]); |
295 | if (!v9ses->cachetag) { | ||
296 | ret = -ENOMEM; | ||
297 | goto free_and_return; | ||
298 | } | ||
295 | #endif | 299 | #endif |
296 | break; | 300 | break; |
297 | case Opt_cache: | 301 | case Opt_cache: |
@@ -471,6 +475,9 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses, | |||
471 | return fid; | 475 | return fid; |
472 | 476 | ||
473 | err_clnt: | 477 | err_clnt: |
478 | #ifdef CONFIG_9P_FSCACHE | ||
479 | kfree(v9ses->cachetag); | ||
480 | #endif | ||
474 | p9_client_destroy(v9ses->clnt); | 481 | p9_client_destroy(v9ses->clnt); |
475 | err_names: | 482 | err_names: |
476 | kfree(v9ses->uname); | 483 | kfree(v9ses->uname); |