All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 9p: check memory allocation result for cachetag
@ 2018-03-21  6:48 Chengguang Xu
  0 siblings, 0 replies; only message in thread
From: Chengguang Xu @ 2018-03-21  6:48 UTC (permalink / raw)
  To: ericvh, rminnich, lucho; +Cc: v9fs-developer, linux-kernel, Chengguang Xu

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

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 fs/9p/v9fs.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 8fb89dd..e622f0f 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)
 #ifdef CONFIG_9P_FSCACHE
 			kfree(v9ses->cachetag);
 			v9ses->cachetag = match_strdup(&args[0]);
+			if (!v9ses->cachetag) {
+				ret = -ENOMEM;
+				goto free_and_return;
+			}
 #endif
 			break;
 		case Opt_cache:
@@ -471,6 +475,9 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
 	return fid;
 
 err_clnt:
+#ifdef CONFIG_9P_FSCACHE
+	kfree(v9ses->cachetag);
+#endif
 	p9_client_destroy(v9ses->clnt);
 err_names:
 	kfree(v9ses->uname);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-03-21  6:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-21  6:48 [PATCH] 9p: check memory allocation result for cachetag Chengguang Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.