diff options
Diffstat (limited to 'net/9p/client.c')
| -rw-r--r-- | net/9p/client.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/net/9p/client.c b/net/9p/client.c index 84e087e24146..2ffe40cf2f01 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
| @@ -64,21 +64,30 @@ static match_table_t tokens = { | |||
| 64 | * @options: options string passed from mount | 64 | * @options: options string passed from mount |
| 65 | * @v9ses: existing v9fs session information | 65 | * @v9ses: existing v9fs session information |
| 66 | * | 66 | * |
| 67 | * Return 0 upon success, -ERRNO upon failure | ||
| 67 | */ | 68 | */ |
| 68 | 69 | ||
| 69 | static void parse_opts(char *options, struct p9_client *clnt) | 70 | static int parse_opts(char *opts, struct p9_client *clnt) |
| 70 | { | 71 | { |
| 72 | char *options; | ||
| 71 | char *p; | 73 | char *p; |
| 72 | substring_t args[MAX_OPT_ARGS]; | 74 | substring_t args[MAX_OPT_ARGS]; |
| 73 | int option; | 75 | int option; |
| 74 | int ret; | 76 | int ret = 0; |
| 75 | 77 | ||
| 76 | clnt->trans_mod = v9fs_default_trans(); | 78 | clnt->trans_mod = v9fs_default_trans(); |
| 77 | clnt->dotu = 1; | 79 | clnt->dotu = 1; |
| 78 | clnt->msize = 8192; | 80 | clnt->msize = 8192; |
| 79 | 81 | ||
| 80 | if (!options) | 82 | if (!opts) |
| 81 | return; | 83 | return 0; |
| 84 | |||
| 85 | options = kstrdup(opts, GFP_KERNEL); | ||
| 86 | if (!options) { | ||
| 87 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
| 88 | "failed to allocate copy of option string\n"); | ||
| 89 | return -ENOMEM; | ||
| 90 | } | ||
| 82 | 91 | ||
| 83 | while ((p = strsep(&options, ",")) != NULL) { | 92 | while ((p = strsep(&options, ",")) != NULL) { |
| 84 | int token; | 93 | int token; |
| @@ -86,10 +95,11 @@ static void parse_opts(char *options, struct p9_client *clnt) | |||
| 86 | continue; | 95 | continue; |
| 87 | token = match_token(p, tokens, args); | 96 | token = match_token(p, tokens, args); |
| 88 | if (token < Opt_trans) { | 97 | if (token < Opt_trans) { |
| 89 | ret = match_int(&args[0], &option); | 98 | int r = match_int(&args[0], &option); |
| 90 | if (ret < 0) { | 99 | if (r < 0) { |
| 91 | P9_DPRINTK(P9_DEBUG_ERROR, | 100 | P9_DPRINTK(P9_DEBUG_ERROR, |
| 92 | "integer field, but no integer?\n"); | 101 | "integer field, but no integer?\n"); |
| 102 | ret = r; | ||
| 93 | continue; | 103 | continue; |
| 94 | } | 104 | } |
| 95 | } | 105 | } |
| @@ -107,6 +117,8 @@ static void parse_opts(char *options, struct p9_client *clnt) | |||
| 107 | continue; | 117 | continue; |
| 108 | } | 118 | } |
| 109 | } | 119 | } |
| 120 | kfree(options); | ||
| 121 | return ret; | ||
| 110 | } | 122 | } |
| 111 | 123 | ||
| 112 | 124 | ||
| @@ -138,16 +150,20 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) | |||
| 138 | if (!clnt) | 150 | if (!clnt) |
| 139 | return ERR_PTR(-ENOMEM); | 151 | return ERR_PTR(-ENOMEM); |
| 140 | 152 | ||
| 153 | clnt->trans = NULL; | ||
| 141 | spin_lock_init(&clnt->lock); | 154 | spin_lock_init(&clnt->lock); |
| 142 | INIT_LIST_HEAD(&clnt->fidlist); | 155 | INIT_LIST_HEAD(&clnt->fidlist); |
| 143 | clnt->fidpool = p9_idpool_create(); | 156 | clnt->fidpool = p9_idpool_create(); |
| 144 | if (!clnt->fidpool) { | 157 | if (IS_ERR(clnt->fidpool)) { |
| 145 | err = PTR_ERR(clnt->fidpool); | 158 | err = PTR_ERR(clnt->fidpool); |
| 146 | clnt->fidpool = NULL; | 159 | clnt->fidpool = NULL; |
| 147 | goto error; | 160 | goto error; |
| 148 | } | 161 | } |
| 149 | 162 | ||
| 150 | parse_opts(options, clnt); | 163 | err = parse_opts(options, clnt); |
| 164 | if (err < 0) | ||
| 165 | goto error; | ||
| 166 | |||
| 151 | if (clnt->trans_mod == NULL) { | 167 | if (clnt->trans_mod == NULL) { |
| 152 | err = -EPROTONOSUPPORT; | 168 | err = -EPROTONOSUPPORT; |
| 153 | P9_DPRINTK(P9_DEBUG_ERROR, | 169 | P9_DPRINTK(P9_DEBUG_ERROR, |
