From dda6b022f3222f09d3fb49f5dfabd31d33e0d10b Mon Sep 17 00:00:00 2001 From: Latchesar Ionkov Date: Tue, 6 Nov 2007 08:02:53 -0600 Subject: 9p: fix memory leak in v9fs_get_sb This patch fixes a memory leak in v9fs_get_sb. Signed-off-by: Latchesar Ionkov Acked-by: Eric Van Hensbergen --- fs/9p/vfs_super.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index bb0cef9a6b8..678c02f1ae2 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c @@ -119,6 +119,7 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags, P9_DPRINTK(P9_DEBUG_VFS, " \n"); + st = NULL; v9ses = kzalloc(sizeof(struct v9fs_session_info), GFP_KERNEL); if (!v9ses) return -ENOMEM; @@ -164,10 +165,12 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags, root->d_inode->i_ino = v9fs_qid2ino(&st->qid); v9fs_stat2inode(st, root->d_inode, sb); v9fs_fid_add(root, fid); + kfree(st); return simple_set_mnt(mnt, sb); error: + kfree(st); if (fid) p9_client_clunk(fid); -- cgit v1.2.3 From 8999e04f3b7930f0c6f091a541237de51d8dd372 Mon Sep 17 00:00:00 2001 From: Latchesar Ionkov Date: Tue, 6 Nov 2007 08:02:53 -0600 Subject: 9p: use copy of the options value instead of original v9fs_parse_options function uses strsep which modifies the value of the v9ses->options field. That modified value is later passed to the function that creates the transport potentially making the transport creation function to fail. This patch creates a copy of v9ses->option field that v9fs_parse_options function uses instead of the original value. Signed-off-by: Latchesar Ionkov Acked-by: Eric Van Hensbergen --- fs/9p/v9fs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 756f7e9beb2..fbb12dadba8 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -82,7 +82,7 @@ static match_table_t tokens = { static void v9fs_parse_options(struct v9fs_session_info *v9ses) { - char *options = v9ses->options; + char *options; substring_t args[MAX_OPT_ARGS]; char *p; int option; @@ -96,9 +96,10 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses) v9ses->cache = 0; v9ses->trans = v9fs_default_trans(); - if (!options) + if (!v9ses->options) return; + options = kstrdup(v9ses->options, GFP_KERNEL); while ((p = strsep(&options, ",")) != NULL) { int token; if (!*p) @@ -169,6 +170,7 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses) continue; } } + kfree(options); } /** -- cgit v1.2.3 From dd1a458412c358f8b4550d7e7df88982c88ce408 Mon Sep 17 00:00:00 2001 From: Latchesar Ionkov Date: Tue, 6 Nov 2007 08:02:53 -0600 Subject: 9p: return NULL when trans not found v9fs_match_trans function returns arbitrary transport module instead of NULL when the requested transport is not registered. This patch modifies the function to return NULL in that case. Signed-off-by: Latchesar Ionkov Acked-by: Eric Van Hensbergen --- net/9p/mod.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/9p/mod.c b/net/9p/mod.c index 41d70f47375..8f9763a9dc1 100644 --- a/net/9p/mod.c +++ b/net/9p/mod.c @@ -76,9 +76,9 @@ struct p9_trans_module *v9fs_match_trans(const substring_t *name) list_for_each(p, &v9fs_trans_list) { t = list_entry(p, struct p9_trans_module, list); if (strncmp(t->name, name->from, name->to-name->from) == 0) - break; + return t; } - return t; + return NULL; } EXPORT_SYMBOL(v9fs_match_trans); -- cgit v1.2.3 From 55762690e2696d7b5034d85d1fbeb620841220c9 Mon Sep 17 00:00:00 2001 From: Latchesar Ionkov Date: Tue, 6 Nov 2007 08:02:53 -0600 Subject: 9p: add missing end-of-options record for trans_fd The list of options that the fd transport accepts is missing end-of-options marker. This patch adds it. Signed-off-by: Latchesar Ionkov Acked-by: Eric Van Hensbergen --- net/9p/trans_fd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index 30269a4ff22..62332ed9da4 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c @@ -62,13 +62,14 @@ struct p9_trans_fd { enum { /* Options that take integer arguments */ - Opt_port, Opt_rfdno, Opt_wfdno, + Opt_port, Opt_rfdno, Opt_wfdno, Opt_err, }; static match_table_t tokens = { {Opt_port, "port=%u"}, {Opt_rfdno, "rfdno=%u"}, {Opt_wfdno, "wfdno=%u"}, + {Opt_err, NULL}, }; /** -- cgit v1.2.3