aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/rbd.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 14d0a3c9f96a..2f2d194ca3d4 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -391,7 +391,9 @@ static int parse_rbd_opts_token(char *c, void *private)
391 * Get a ceph client with specific addr and configuration, if one does 391 * Get a ceph client with specific addr and configuration, if one does
392 * not exist create it. 392 * not exist create it.
393 */ 393 */
394static struct rbd_client *rbd_get_client(const char *mon_addr, char *options) 394static struct rbd_client *rbd_get_client(const char *mon_addr,
395 size_t mon_addr_len,
396 char *options)
395{ 397{
396 struct rbd_client *rbdc; 398 struct rbd_client *rbdc;
397 struct ceph_options *opt; 399 struct ceph_options *opt;
@@ -404,7 +406,7 @@ static struct rbd_client *rbd_get_client(const char *mon_addr, char *options)
404 rbd_opts->notify_timeout = RBD_NOTIFY_TIMEOUT_DEFAULT; 406 rbd_opts->notify_timeout = RBD_NOTIFY_TIMEOUT_DEFAULT;
405 407
406 opt = ceph_parse_options(options, mon_addr, 408 opt = ceph_parse_options(options, mon_addr,
407 mon_addr + strlen(mon_addr), 409 mon_addr + mon_addr_len,
408 parse_rbd_opts_token, rbd_opts); 410 parse_rbd_opts_token, rbd_opts);
409 if (IS_ERR(opt)) { 411 if (IS_ERR(opt)) {
410 kfree(rbd_opts); 412 kfree(rbd_opts);
@@ -2283,7 +2285,7 @@ static inline size_t copy_token(const char **buf,
2283static int rbd_add_parse_args(struct rbd_device *rbd_dev, 2285static int rbd_add_parse_args(struct rbd_device *rbd_dev,
2284 const char *buf, 2286 const char *buf,
2285 char *mon_addrs, 2287 char *mon_addrs,
2286 size_t mon_addrs_size, 2288 size_t *mon_addrs_size,
2287 char *options, 2289 char *options,
2288 size_t options_size) 2290 size_t options_size)
2289{ 2291{
@@ -2291,9 +2293,10 @@ static int rbd_add_parse_args(struct rbd_device *rbd_dev,
2291 2293
2292 /* The first four tokens are required */ 2294 /* The first four tokens are required */
2293 2295
2294 len = copy_token(&buf, mon_addrs, mon_addrs_size); 2296 len = copy_token(&buf, mon_addrs, *mon_addrs_size);
2295 if (!len || len >= mon_addrs_size) 2297 if (!len || len >= *mon_addrs_size)
2296 return -EINVAL; 2298 return -EINVAL;
2299 *mon_addrs_size = len + 1;
2297 2300
2298 len = copy_token(&buf, options, options_size); 2301 len = copy_token(&buf, options, options_size);
2299 if (!len || len >= options_size) 2302 if (!len || len >= options_size)
@@ -2335,6 +2338,7 @@ static ssize_t rbd_add(struct bus_type *bus,
2335{ 2338{
2336 struct rbd_device *rbd_dev; 2339 struct rbd_device *rbd_dev;
2337 char *mon_addrs = NULL; 2340 char *mon_addrs = NULL;
2341 size_t mon_addrs_size;
2338 char *options = NULL; 2342 char *options = NULL;
2339 struct ceph_osd_client *osdc; 2343 struct ceph_osd_client *osdc;
2340 int rc = -ENOMEM; 2344 int rc = -ENOMEM;
@@ -2368,12 +2372,14 @@ static ssize_t rbd_add(struct bus_type *bus,
2368 sprintf(rbd_dev->name, "%s%d", RBD_DRV_NAME, rbd_dev->id); 2372 sprintf(rbd_dev->name, "%s%d", RBD_DRV_NAME, rbd_dev->id);
2369 2373
2370 /* parse add command */ 2374 /* parse add command */
2371 rc = rbd_add_parse_args(rbd_dev, buf, mon_addrs, count, 2375 mon_addrs_size = count;
2376 rc = rbd_add_parse_args(rbd_dev, buf, mon_addrs, &mon_addrs_size,
2372 options, count); 2377 options, count);
2373 if (rc) 2378 if (rc)
2374 goto err_put_id; 2379 goto err_put_id;
2375 2380
2376 rbd_dev->rbd_client = rbd_get_client(mon_addrs, options); 2381 rbd_dev->rbd_client = rbd_get_client(mon_addrs, mon_addrs_size - 1,
2382 options);
2377 if (IS_ERR(rbd_dev->rbd_client)) { 2383 if (IS_ERR(rbd_dev->rbd_client)) {
2378 rc = PTR_ERR(rbd_dev->rbd_client); 2384 rc = PTR_ERR(rbd_dev->rbd_client);
2379 goto err_put_id; 2385 goto err_put_id;