diff options
-rw-r--r-- | drivers/md/dm-delay.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c index 6928c136d3c5..0fd1f7c2e162 100644 --- a/drivers/md/dm-delay.c +++ b/drivers/md/dm-delay.c | |||
@@ -163,34 +163,32 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
163 | goto bad; | 163 | goto bad; |
164 | } | 164 | } |
165 | 165 | ||
166 | if (argc == 3) { | 166 | dc->dev_write = NULL; |
167 | dc->dev_write = NULL; | 167 | if (argc == 3) |
168 | goto out; | 168 | goto out; |
169 | } | ||
170 | 169 | ||
171 | if (sscanf(argv[4], "%llu", &tmpll) != 1) { | 170 | if (sscanf(argv[4], "%llu", &tmpll) != 1) { |
172 | ti->error = "Invalid write device sector"; | 171 | ti->error = "Invalid write device sector"; |
173 | goto bad; | 172 | goto bad_dev_read; |
174 | } | 173 | } |
175 | dc->start_write = tmpll; | 174 | dc->start_write = tmpll; |
176 | 175 | ||
177 | if (sscanf(argv[5], "%u", &dc->write_delay) != 1) { | 176 | if (sscanf(argv[5], "%u", &dc->write_delay) != 1) { |
178 | ti->error = "Invalid write delay"; | 177 | ti->error = "Invalid write delay"; |
179 | goto bad; | 178 | goto bad_dev_read; |
180 | } | 179 | } |
181 | 180 | ||
182 | if (dm_get_device(ti, argv[3], dc->start_write, ti->len, | 181 | if (dm_get_device(ti, argv[3], dc->start_write, ti->len, |
183 | dm_table_get_mode(ti->table), &dc->dev_write)) { | 182 | dm_table_get_mode(ti->table), &dc->dev_write)) { |
184 | ti->error = "Write device lookup failed"; | 183 | ti->error = "Write device lookup failed"; |
185 | dm_put_device(ti, dc->dev_read); | 184 | goto bad_dev_read; |
186 | goto bad; | ||
187 | } | 185 | } |
188 | 186 | ||
189 | out: | 187 | out: |
190 | dc->delayed_pool = mempool_create_slab_pool(128, delayed_cache); | 188 | dc->delayed_pool = mempool_create_slab_pool(128, delayed_cache); |
191 | if (!dc->delayed_pool) { | 189 | if (!dc->delayed_pool) { |
192 | DMERR("Couldn't create delayed bio pool."); | 190 | DMERR("Couldn't create delayed bio pool."); |
193 | goto bad; | 191 | goto bad_dev_write; |
194 | } | 192 | } |
195 | 193 | ||
196 | setup_timer(&dc->delay_timer, handle_delayed_timer, (unsigned long)dc); | 194 | setup_timer(&dc->delay_timer, handle_delayed_timer, (unsigned long)dc); |
@@ -203,6 +201,11 @@ out: | |||
203 | ti->private = dc; | 201 | ti->private = dc; |
204 | return 0; | 202 | return 0; |
205 | 203 | ||
204 | bad_dev_write: | ||
205 | if (dc->dev_write) | ||
206 | dm_put_device(ti, dc->dev_write); | ||
207 | bad_dev_read: | ||
208 | dm_put_device(ti, dc->dev_read); | ||
206 | bad: | 209 | bad: |
207 | kfree(dc); | 210 | kfree(dc); |
208 | return -EINVAL; | 211 | return -EINVAL; |