Commit 636d5786 authored by Milan Broz's avatar Milan Broz Committed by Alasdair G Kergon

dm crypt: tidy labels

Replace numbers with names in labels in error paths, to avoid confusion
when new one get added between existing ones.
Signed-off-by: default avatarMilan Broz <mbroz@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent d469f841
...@@ -771,7 +771,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -771,7 +771,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
if (crypt_set_key(cc, argv[1])) { if (crypt_set_key(cc, argv[1])) {
ti->error = "Error decoding key"; ti->error = "Error decoding key";
goto bad1; goto bad_cipher;
} }
/* Compatiblity mode for old dm-crypt cipher strings */ /* Compatiblity mode for old dm-crypt cipher strings */
...@@ -782,19 +782,19 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -782,19 +782,19 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
if (strcmp(chainmode, "ecb") && !ivmode) { if (strcmp(chainmode, "ecb") && !ivmode) {
ti->error = "This chaining mode requires an IV mechanism"; ti->error = "This chaining mode requires an IV mechanism";
goto bad1; goto bad_cipher;
} }
if (snprintf(cc->cipher, CRYPTO_MAX_ALG_NAME, "%s(%s)", if (snprintf(cc->cipher, CRYPTO_MAX_ALG_NAME, "%s(%s)",
chainmode, cipher) >= CRYPTO_MAX_ALG_NAME) { chainmode, cipher) >= CRYPTO_MAX_ALG_NAME) {
ti->error = "Chain mode + cipher name is too long"; ti->error = "Chain mode + cipher name is too long";
goto bad1; goto bad_cipher;
} }
tfm = crypto_alloc_blkcipher(cc->cipher, 0, CRYPTO_ALG_ASYNC); tfm = crypto_alloc_blkcipher(cc->cipher, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm)) { if (IS_ERR(tfm)) {
ti->error = "Error allocating crypto tfm"; ti->error = "Error allocating crypto tfm";
goto bad1; goto bad_cipher;
} }
strcpy(cc->cipher, cipher); strcpy(cc->cipher, cipher);
...@@ -818,12 +818,12 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -818,12 +818,12 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
cc->iv_gen_ops = &crypt_iv_null_ops; cc->iv_gen_ops = &crypt_iv_null_ops;
else { else {
ti->error = "Invalid IV mode"; ti->error = "Invalid IV mode";
goto bad2; goto bad_ivmode;
} }
if (cc->iv_gen_ops && cc->iv_gen_ops->ctr && if (cc->iv_gen_ops && cc->iv_gen_ops->ctr &&
cc->iv_gen_ops->ctr(cc, ti, ivopts) < 0) cc->iv_gen_ops->ctr(cc, ti, ivopts) < 0)
goto bad2; goto bad_ivmode;
cc->iv_size = crypto_blkcipher_ivsize(tfm); cc->iv_size = crypto_blkcipher_ivsize(tfm);
if (cc->iv_size) if (cc->iv_size)
...@@ -842,13 +842,13 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -842,13 +842,13 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
cc->io_pool = mempool_create_slab_pool(MIN_IOS, _crypt_io_pool); cc->io_pool = mempool_create_slab_pool(MIN_IOS, _crypt_io_pool);
if (!cc->io_pool) { if (!cc->io_pool) {
ti->error = "Cannot allocate crypt io mempool"; ti->error = "Cannot allocate crypt io mempool";
goto bad3; goto bad_slab_pool;
} }
cc->page_pool = mempool_create_page_pool(MIN_POOL_PAGES, 0); cc->page_pool = mempool_create_page_pool(MIN_POOL_PAGES, 0);
if (!cc->page_pool) { if (!cc->page_pool) {
ti->error = "Cannot allocate page mempool"; ti->error = "Cannot allocate page mempool";
goto bad4; goto bad_page_pool;
} }
cc->bs = bioset_create(MIN_IOS, MIN_IOS); cc->bs = bioset_create(MIN_IOS, MIN_IOS);
...@@ -859,25 +859,25 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -859,25 +859,25 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
if (crypto_blkcipher_setkey(tfm, cc->key, key_size) < 0) { if (crypto_blkcipher_setkey(tfm, cc->key, key_size) < 0) {
ti->error = "Error setting key"; ti->error = "Error setting key";
goto bad5; goto bad_device;
} }
if (sscanf(argv[2], "%llu", &tmpll) != 1) { if (sscanf(argv[2], "%llu", &tmpll) != 1) {
ti->error = "Invalid iv_offset sector"; ti->error = "Invalid iv_offset sector";
goto bad5; goto bad_device;
} }
cc->iv_offset = tmpll; cc->iv_offset = tmpll;
if (sscanf(argv[4], "%llu", &tmpll) != 1) { if (sscanf(argv[4], "%llu", &tmpll) != 1) {
ti->error = "Invalid device sector"; ti->error = "Invalid device sector";
goto bad5; goto bad_device;
} }
cc->start = tmpll; cc->start = tmpll;
if (dm_get_device(ti, argv[3], cc->start, ti->len, if (dm_get_device(ti, argv[3], cc->start, ti->len,
dm_table_get_mode(ti->table), &cc->dev)) { dm_table_get_mode(ti->table), &cc->dev)) {
ti->error = "Device lookup failed"; ti->error = "Device lookup failed";
goto bad5; goto bad_device;
} }
if (ivmode && cc->iv_gen_ops) { if (ivmode && cc->iv_gen_ops) {
...@@ -886,7 +886,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -886,7 +886,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
cc->iv_mode = kmalloc(strlen(ivmode) + 1, GFP_KERNEL); cc->iv_mode = kmalloc(strlen(ivmode) + 1, GFP_KERNEL);
if (!cc->iv_mode) { if (!cc->iv_mode) {
ti->error = "Error kmallocing iv_mode string"; ti->error = "Error kmallocing iv_mode string";
goto bad_iv_mode; goto bad_ivmode_string;
} }
strcpy(cc->iv_mode, ivmode); strcpy(cc->iv_mode, ivmode);
} else } else
...@@ -911,20 +911,20 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -911,20 +911,20 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
destroy_workqueue(cc->io_queue); destroy_workqueue(cc->io_queue);
bad_io_queue: bad_io_queue:
kfree(cc->iv_mode); kfree(cc->iv_mode);
bad_iv_mode: bad_ivmode_string:
dm_put_device(ti, cc->dev); dm_put_device(ti, cc->dev);
bad5: bad_device:
bioset_free(cc->bs); bioset_free(cc->bs);
bad_bs: bad_bs:
mempool_destroy(cc->page_pool); mempool_destroy(cc->page_pool);
bad4: bad_page_pool:
mempool_destroy(cc->io_pool); mempool_destroy(cc->io_pool);
bad3: bad_slab_pool:
if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) if (cc->iv_gen_ops && cc->iv_gen_ops->dtr)
cc->iv_gen_ops->dtr(cc); cc->iv_gen_ops->dtr(cc);
bad2: bad_ivmode:
crypto_free_blkcipher(tfm); crypto_free_blkcipher(tfm);
bad1: bad_cipher:
/* Must zero key material before freeing */ /* Must zero key material before freeing */
memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8)); memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8));
kfree(cc); kfree(cc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment