aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p
diff options
context:
space:
mode:
authorEric Van Hensbergen <ericvh@gmail.com>2010-02-08 18:59:34 -0500
committerEric Van Hensbergen <ericvh@gmail.com>2010-02-08 18:59:34 -0500
commitbf2d29c64dd777e9a40bc4533e721944a590250f (patch)
tree4425f4ab1cee9cdf24a4ac92122682c929c24964 /fs/9p
parentfb786100f7c75e154e63d0f5a2982e6d46dfb602 (diff)
9p: fix memory leak in v9fs_parse_options()
If match_strdup() fail this function exits without freeing the options string. Signed-off-by: Venkateswararao Jujjuri <jvrao@us.ibm.com> Sigend-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/v9fs.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 6848788a13db..7d6c2139891d 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -103,8 +103,10 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
103 return 0; 103 return 0;
104 104
105 tmp_options = kstrdup(opts, GFP_KERNEL); 105 tmp_options = kstrdup(opts, GFP_KERNEL);
106 if (!tmp_options) 106 if (!tmp_options) {
107 ret = -ENOMEM;
107 goto fail_option_alloc; 108 goto fail_option_alloc;
109 }
108 options = tmp_options; 110 options = tmp_options;
109 111
110 while ((p = strsep(&options, ",")) != NULL) { 112 while ((p = strsep(&options, ",")) != NULL) {
@@ -160,8 +162,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
160 break; 162 break;
161 case Opt_cache: 163 case Opt_cache:
162 s = match_strdup(&args[0]); 164 s = match_strdup(&args[0]);
163 if (!s) 165 if (!s) {
164 goto fail_option_alloc; 166 ret = -ENOMEM;
167 P9_DPRINTK(P9_DEBUG_ERROR,
168 "problem allocating copy of cache arg\n");
169 goto free_and_return;
170 }
165 171
166 if (strcmp(s, "loose") == 0) 172 if (strcmp(s, "loose") == 0)
167 v9ses->cache = CACHE_LOOSE; 173 v9ses->cache = CACHE_LOOSE;
@@ -174,8 +180,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
174 180
175 case Opt_access: 181 case Opt_access:
176 s = match_strdup(&args[0]); 182 s = match_strdup(&args[0]);
177 if (!s) 183 if (!s) {
178 goto fail_option_alloc; 184 ret = -ENOMEM;
185 P9_DPRINTK(P9_DEBUG_ERROR,
186 "problem allocating copy of access arg\n");
187 goto free_and_return;
188 }
179 189
180 v9ses->flags &= ~V9FS_ACCESS_MASK; 190 v9ses->flags &= ~V9FS_ACCESS_MASK;
181 if (strcmp(s, "user") == 0) 191 if (strcmp(s, "user") == 0)
@@ -196,13 +206,10 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
196 } 206 }
197 } 207 }
198 208
209free_and_return:
199 kfree(tmp_options); 210 kfree(tmp_options);
200 return ret;
201
202fail_option_alloc: 211fail_option_alloc:
203 P9_DPRINTK(P9_DEBUG_ERROR, 212 return ret;
204 "failed to allocate copy of option argument\n");
205 return -ENOMEM;
206} 213}
207 214
208/** 215/**