aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p
diff options
context:
space:
mode:
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/v9fs.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 79d310c00188..5c1ccaf0416c 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -73,16 +73,17 @@ static match_table_t tokens = {
73 * v9fs_parse_options - parse mount options into session structure 73 * v9fs_parse_options - parse mount options into session structure
74 * @v9ses: existing v9fs session information 74 * @v9ses: existing v9fs session information
75 * 75 *
76 * Return 0 upon success, -ERRNO upon failure.
76 */ 77 */
77 78
78static void v9fs_parse_options(struct v9fs_session_info *v9ses) 79static int v9fs_parse_options(struct v9fs_session_info *v9ses)
79{ 80{
80 char *options; 81 char *options;
81 substring_t args[MAX_OPT_ARGS]; 82 substring_t args[MAX_OPT_ARGS];
82 char *p; 83 char *p;
83 int option = 0; 84 int option = 0;
84 char *s, *e; 85 char *s, *e;
85 int ret; 86 int ret = 0;
86 87
87 /* setup defaults */ 88 /* setup defaults */
88 v9ses->afid = ~0; 89 v9ses->afid = ~0;
@@ -90,19 +91,26 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
90 v9ses->cache = 0; 91 v9ses->cache = 0;
91 92
92 if (!v9ses->options) 93 if (!v9ses->options)
93 return; 94 return 0;
94 95
95 options = kstrdup(v9ses->options, GFP_KERNEL); 96 options = kstrdup(v9ses->options, GFP_KERNEL);
97 if (!options) {
98 P9_DPRINTK(P9_DEBUG_ERROR,
99 "failed to allocate copy of option string\n");
100 return -ENOMEM;
101 }
102
96 while ((p = strsep(&options, ",")) != NULL) { 103 while ((p = strsep(&options, ",")) != NULL) {
97 int token; 104 int token;
98 if (!*p) 105 if (!*p)
99 continue; 106 continue;
100 token = match_token(p, tokens, args); 107 token = match_token(p, tokens, args);
101 if (token < Opt_uname) { 108 if (token < Opt_uname) {
102 ret = match_int(&args[0], &option); 109 int r = match_int(&args[0], &option);
103 if (ret < 0) { 110 if (r < 0) {
104 P9_DPRINTK(P9_DEBUG_ERROR, 111 P9_DPRINTK(P9_DEBUG_ERROR,
105 "integer field, but no integer?\n"); 112 "integer field, but no integer?\n");
113 ret = r;
106 continue; 114 continue;
107 } 115 }
108 } 116 }
@@ -138,6 +146,13 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
138 146
139 case Opt_access: 147 case Opt_access:
140 s = match_strdup(&args[0]); 148 s = match_strdup(&args[0]);
149 if (!s) {
150 P9_DPRINTK(P9_DEBUG_ERROR,
151 "failed to allocate copy"
152 " of option argument\n");
153 ret = -ENOMEM;
154 break;
155 }
141 v9ses->flags &= ~V9FS_ACCESS_MASK; 156 v9ses->flags &= ~V9FS_ACCESS_MASK;
142 if (strcmp(s, "user") == 0) 157 if (strcmp(s, "user") == 0)
143 v9ses->flags |= V9FS_ACCESS_USER; 158 v9ses->flags |= V9FS_ACCESS_USER;
@@ -157,6 +172,7 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
157 } 172 }
158 } 173 }
159 kfree(options); 174 kfree(options);
175 return ret;
160} 176}
161 177
162/** 178/**
@@ -172,6 +188,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
172{ 188{
173 int retval = -EINVAL; 189 int retval = -EINVAL;
174 struct p9_fid *fid; 190 struct p9_fid *fid;
191 int rc;
175 192
176 v9ses->uname = __getname(); 193 v9ses->uname = __getname();
177 if (!v9ses->uname) 194 if (!v9ses->uname)
@@ -190,7 +207,18 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
190 v9ses->dfltuid = V9FS_DEFUID; 207 v9ses->dfltuid = V9FS_DEFUID;
191 v9ses->dfltgid = V9FS_DEFGID; 208 v9ses->dfltgid = V9FS_DEFGID;
192 v9ses->options = kstrdup(data, GFP_KERNEL); 209 v9ses->options = kstrdup(data, GFP_KERNEL);
193 v9fs_parse_options(v9ses); 210 if (!v9ses->options) {
211 P9_DPRINTK(P9_DEBUG_ERROR,
212 "failed to allocate copy of option string\n");
213 retval = -ENOMEM;
214 goto error;
215 }
216
217 rc = v9fs_parse_options(v9ses);
218 if (rc < 0) {
219 retval = rc;
220 goto error;
221 }
194 222
195 v9ses->clnt = p9_client_create(dev_name, v9ses->options); 223 v9ses->clnt = p9_client_create(dev_name, v9ses->options);
196 224