diff options
Diffstat (limited to 'net/9p/trans_fd.c')
-rw-r--r-- | net/9p/trans_fd.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index c6eda999fa7d..97b103b70499 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -1196,35 +1196,46 @@ void p9_conn_cancel(struct p9_conn *m, int err) | |||
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | /** | 1198 | /** |
1199 | * v9fs_parse_options - parse mount options into session structure | 1199 | * parse_options - parse mount options into session structure |
1200 | * @options: options string passed from mount | 1200 | * @options: options string passed from mount |
1201 | * @opts: transport-specific structure to parse options into | 1201 | * @opts: transport-specific structure to parse options into |
1202 | * | 1202 | * |
1203 | * Returns 0 upon success, -ERRNO upon failure | ||
1203 | */ | 1204 | */ |
1204 | 1205 | ||
1205 | static void parse_opts(char *options, struct p9_fd_opts *opts) | 1206 | static int parse_opts(char *params, struct p9_fd_opts *opts) |
1206 | { | 1207 | { |
1207 | char *p; | 1208 | char *p; |
1208 | substring_t args[MAX_OPT_ARGS]; | 1209 | substring_t args[MAX_OPT_ARGS]; |
1209 | int option; | 1210 | int option; |
1211 | char *options; | ||
1210 | int ret; | 1212 | int ret; |
1211 | 1213 | ||
1212 | opts->port = P9_PORT; | 1214 | opts->port = P9_PORT; |
1213 | opts->rfd = ~0; | 1215 | opts->rfd = ~0; |
1214 | opts->wfd = ~0; | 1216 | opts->wfd = ~0; |
1215 | 1217 | ||
1216 | if (!options) | 1218 | if (!params) |
1217 | return; | 1219 | return 0; |
1220 | |||
1221 | options = kstrdup(params, GFP_KERNEL); | ||
1222 | if (!options) { | ||
1223 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
1224 | "failed to allocate copy of option string\n"); | ||
1225 | return -ENOMEM; | ||
1226 | } | ||
1218 | 1227 | ||
1219 | while ((p = strsep(&options, ",")) != NULL) { | 1228 | while ((p = strsep(&options, ",")) != NULL) { |
1220 | int token; | 1229 | int token; |
1230 | int r; | ||
1221 | if (!*p) | 1231 | if (!*p) |
1222 | continue; | 1232 | continue; |
1223 | token = match_token(p, tokens, args); | 1233 | token = match_token(p, tokens, args); |
1224 | ret = match_int(&args[0], &option); | 1234 | r = match_int(&args[0], &option); |
1225 | if (ret < 0) { | 1235 | if (r < 0) { |
1226 | P9_DPRINTK(P9_DEBUG_ERROR, | 1236 | P9_DPRINTK(P9_DEBUG_ERROR, |
1227 | "integer field, but no integer?\n"); | 1237 | "integer field, but no integer?\n"); |
1238 | ret = r; | ||
1228 | continue; | 1239 | continue; |
1229 | } | 1240 | } |
1230 | switch (token) { | 1241 | switch (token) { |
@@ -1241,6 +1252,8 @@ static void parse_opts(char *options, struct p9_fd_opts *opts) | |||
1241 | continue; | 1252 | continue; |
1242 | } | 1253 | } |
1243 | } | 1254 | } |
1255 | kfree(options); | ||
1256 | return 0; | ||
1244 | } | 1257 | } |
1245 | 1258 | ||
1246 | static int p9_fd_open(struct p9_trans *trans, int rfd, int wfd) | 1259 | static int p9_fd_open(struct p9_trans *trans, int rfd, int wfd) |
@@ -1430,7 +1443,9 @@ p9_trans_create_tcp(const char *addr, char *args, int msize, unsigned char dotu) | |||
1430 | struct p9_fd_opts opts; | 1443 | struct p9_fd_opts opts; |
1431 | struct p9_trans_fd *p; | 1444 | struct p9_trans_fd *p; |
1432 | 1445 | ||
1433 | parse_opts(args, &opts); | 1446 | err = parse_opts(args, &opts); |
1447 | if (err < 0) | ||
1448 | return ERR_PTR(err); | ||
1434 | 1449 | ||
1435 | csocket = NULL; | 1450 | csocket = NULL; |
1436 | trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); | 1451 | trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); |