diff options
Diffstat (limited to 'fs/9p/v9fs.c')
-rw-r--r-- | fs/9p/v9fs.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index cf62b05e296a..7d6c2139891d 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c | |||
@@ -84,7 +84,7 @@ static const match_table_t tokens = { | |||
84 | 84 | ||
85 | static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | 85 | static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) |
86 | { | 86 | { |
87 | char *options; | 87 | char *options, *tmp_options; |
88 | substring_t args[MAX_OPT_ARGS]; | 88 | substring_t args[MAX_OPT_ARGS]; |
89 | char *p; | 89 | char *p; |
90 | int option = 0; | 90 | int option = 0; |
@@ -102,9 +102,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
102 | if (!opts) | 102 | if (!opts) |
103 | return 0; | 103 | return 0; |
104 | 104 | ||
105 | options = kstrdup(opts, GFP_KERNEL); | 105 | tmp_options = kstrdup(opts, GFP_KERNEL); |
106 | if (!options) | 106 | if (!tmp_options) { |
107 | ret = -ENOMEM; | ||
107 | goto fail_option_alloc; | 108 | goto fail_option_alloc; |
109 | } | ||
110 | options = tmp_options; | ||
108 | 111 | ||
109 | while ((p = strsep(&options, ",")) != NULL) { | 112 | while ((p = strsep(&options, ",")) != NULL) { |
110 | int token; | 113 | int token; |
@@ -159,8 +162,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
159 | break; | 162 | break; |
160 | case Opt_cache: | 163 | case Opt_cache: |
161 | s = match_strdup(&args[0]); | 164 | s = match_strdup(&args[0]); |
162 | if (!s) | 165 | if (!s) { |
163 | 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 | } | ||
164 | 171 | ||
165 | if (strcmp(s, "loose") == 0) | 172 | if (strcmp(s, "loose") == 0) |
166 | v9ses->cache = CACHE_LOOSE; | 173 | v9ses->cache = CACHE_LOOSE; |
@@ -173,8 +180,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
173 | 180 | ||
174 | case Opt_access: | 181 | case Opt_access: |
175 | s = match_strdup(&args[0]); | 182 | s = match_strdup(&args[0]); |
176 | if (!s) | 183 | if (!s) { |
177 | 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 | } | ||
178 | 189 | ||
179 | v9ses->flags &= ~V9FS_ACCESS_MASK; | 190 | v9ses->flags &= ~V9FS_ACCESS_MASK; |
180 | if (strcmp(s, "user") == 0) | 191 | if (strcmp(s, "user") == 0) |
@@ -194,13 +205,11 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
194 | continue; | 205 | continue; |
195 | } | 206 | } |
196 | } | 207 | } |
197 | kfree(options); | ||
198 | return ret; | ||
199 | 208 | ||
209 | free_and_return: | ||
210 | kfree(tmp_options); | ||
200 | fail_option_alloc: | 211 | fail_option_alloc: |
201 | P9_DPRINTK(P9_DEBUG_ERROR, | 212 | return ret; |
202 | "failed to allocate copy of option argument\n"); | ||
203 | return -ENOMEM; | ||
204 | } | 213 | } |
205 | 214 | ||
206 | /** | 215 | /** |