@@ -1628,20 +1628,23 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad;
}
- ret = -EINVAL;
if (sscanf(argv[2], "%llu", &tmpll) != 1) {
ti->error = "Invalid iv_offset sector";
+ ret = -EINVAL;
goto bad;
}
cc->iv_offset = tmpll;
- if (dm_get_device(ti, argv[3], dm_table_get_mode(ti->table), &cc->dev)) {
+ ret = dm_get_device(ti, argv[3], dm_table_get_mode(ti->table),
+ &cc->dev);
+ if (ret) {
ti->error = "Device lookup failed";
goto bad;
}
if (sscanf(argv[4], "%llu", &tmpll) != 1) {
ti->error = "Invalid device sector";
+ ret = -EINVAL;
goto bad;
}
cc->start = tmpll;
@@ -131,6 +131,7 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
{
struct delay_c *dc;
unsigned long long tmpll;
+ int r = -EINVAL;
if (argc != 3 && argc != 6) {
ti->error = "requires exactly 3 or 6 arguments";
@@ -156,12 +157,14 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad;
}
- if (dm_get_device(ti, argv[0], dm_table_get_mode(ti->table),
- &dc->dev_read)) {
+ r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table),
+ &dc->dev_read);
+ if (r) {
ti->error = "Device lookup failed";
goto bad;
}
+ r = -EINVAL;
dc->dev_write = NULL;
if (argc == 3)
goto out;
@@ -177,8 +180,9 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad_dev_read;
}
- if (dm_get_device(ti, argv[3], dm_table_get_mode(ti->table),
- &dc->dev_write)) {
+ r = dm_get_device(ti, argv[3], dm_table_get_mode(ti->table),
+ &dc->dev_write);
+ if (r) {
ti->error = "Write device lookup failed";
goto bad_dev_read;
}
@@ -187,6 +191,7 @@ out:
dc->delayed_pool = mempool_create_slab_pool(128, delayed_cache);
if (!dc->delayed_pool) {
DMERR("Couldn't create delayed bio pool.");
+ r = -ENOMEM;
goto bad_dev_write;
}
@@ -209,7 +214,7 @@ bad_dev_read:
dm_put_device(ti, dc->dev_read);
bad:
kfree(dc);
- return -EINVAL;
+ return r;
}
static void delay_dtr(struct dm_target *ti)
@@ -29,6 +29,7 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv)
{
struct linear_c *lc;
unsigned long long tmp;
+ int r;
if (argc != 2) {
ti->error = "Invalid argument count";
@@ -43,23 +44,22 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv)
if (sscanf(argv[1], "%llu", &tmp) != 1) {
ti->error = "dm-linear: Invalid device sector";
- goto bad;
+ kfree(lc);
+ return -EINVAL;
}
lc->start = tmp;
- if (dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &lc->dev)) {
+ r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &lc->dev);
+ if (r) {
ti->error = "dm-linear: Device lookup failed";
- goto bad;
+ kfree(lc);
+ return r;
}
ti->num_flush_requests = 1;
ti->num_discard_requests = 1;
ti->private = lc;
return 0;
-
- bad:
- kfree(lc);
- return -EINVAL;
}
static void linear_dtr(struct dm_target *ti)
@@ -928,16 +928,18 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
unsigned int mirror, char **argv)
{
unsigned long long offset;
+ int r;
if (sscanf(argv[1], "%llu", &offset) != 1) {
ti->error = "Invalid offset";
return -EINVAL;
}
- if (dm_get_device(ti, argv[0], dm_table_get_mode(ti->table),
- &ms->mirror[mirror].dev)) {
+ r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table),
+ &ms->mirror[mirror].dev);
+ if (r) {
ti->error = "Device lookup failure";
- return -ENXIO;
+ return r;
}
ms->mirror[mirror].ms = ms;
@@ -74,18 +74,19 @@ static inline struct stripe_c *alloc_context(unsigned int stripes)
static int get_stripe(struct dm_target *ti, struct stripe_c *sc,
unsigned int stripe, char **argv)
{
+ int r;
unsigned long long start;
if (sscanf(argv[1], "%llu", &start) != 1)
return -EINVAL;
- if (dm_get_device(ti, argv[0], dm_table_get_mode(ti->table),
- &sc->stripe[stripe].dev))
- return -ENXIO;
+ r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table),
+ &sc->stripe[stripe].dev);
- sc->stripe[stripe].physical_start = start;
+ if (!r)
+ sc->stripe[stripe].physical_start = start;
- return 0;
+ return r;
}
/*