combined badX + bad_anything goto labels are ugly... so fixing it. (apply after async crypto patches) -- Tidy error path in dm-crypt constructor (do not use badX labels). Signed-off-by: Milan Broz --- drivers/md/dm-crypt.c | 54 +++++++++++++++++++++++++------------------------- 1 files changed, 27 insertions(+), 27 deletions(-) Index: linux-2.6.23-rc6/drivers/md/dm-crypt.c =================================================================== --- linux-2.6.23-rc6.orig/drivers/md/dm-crypt.c 2007-09-25 22:12:12.000000000 +0100 +++ linux-2.6.23-rc6/drivers/md/dm-crypt.c 2007-09-25 22:12:14.000000000 +0100 @@ -352,10 +352,10 @@ static void dm_crypt_complete(struct cry crypt_read_done(io); } -static void -crypt_convert_init(struct crypt_config *cc, struct convert_context *ctx, - struct bio *bio_out, struct bio *bio_in, - sector_t sector, int write) +static void crypt_convert_init(struct crypt_config *cc, + struct convert_context *ctx, + struct bio *bio_out, struct bio *bio_in, + sector_t sector, int write) { ctx->bio_in = bio_in; ctx->bio_out = bio_out; @@ -472,13 +472,13 @@ static void crypt_convert(struct crypt_c return -EINPROGRESS; } - static void dm_crypt_bio_destructor(struct bio *bio) - { +static void dm_crypt_bio_destructor(struct bio *bio) +{ struct dm_crypt_io *io = bio->bi_private; struct crypt_config *cc = io->target->private; bio_free(bio, cc->bs); - } +} /* * Generate a new unfragmented bio with the given size @@ -534,7 +534,7 @@ static struct bio *crypt_alloc_buffer(st } static void crypt_free_buffer_pages(struct crypt_config *cc, - struct bio *clone, unsigned int bytes) + struct bio *clone, unsigned int bytes) { unsigned int i, start, end; struct bio_vec *bv; @@ -932,7 +932,7 @@ static int crypt_ctr(struct dm_target *t if (crypt_set_key(cc, argv[1])) { ti->error = "Error decoding key"; - goto bad1; + goto bad_cipher; } /* Compatiblity mode for old dm-crypt cipher strings */ @@ -943,19 +943,19 @@ static int crypt_ctr(struct dm_target *t if (strcmp(chainmode, "ecb") && !ivmode) { ti->error = "This chaining mode requires an IV mechanism"; - goto bad1; + goto bad_cipher; } if (snprintf(cc->cipher, CRYPTO_MAX_ALG_NAME, "%s(%s)", chainmode, cipher) >= CRYPTO_MAX_ALG_NAME) { ti->error = "Chain mode + cipher name is too long"; - goto bad1; + goto bad_cipher; } tfm = crypto_alloc_ablkcipher(cc->cipher, 0, 0); if (IS_ERR(tfm)) { ti->error = "Error allocating crypto tfm"; - goto bad1; + goto bad_cipher; } strcpy(cc->cipher, cipher); @@ -979,12 +979,12 @@ static int crypt_ctr(struct dm_target *t cc->iv_gen_ops = &crypt_iv_null_ops; else { ti->error = "Invalid IV mode"; - goto bad2; + goto bad_ivmode; } if (cc->iv_gen_ops && cc->iv_gen_ops->ctr && cc->iv_gen_ops->ctr(cc, ti, ivopts) < 0) - goto bad2; + goto bad_ivmode; cc->iv_size = crypto_ablkcipher_ivsize(tfm); if (cc->iv_size) @@ -1003,7 +1003,7 @@ static int crypt_ctr(struct dm_target *t cc->io_pool = mempool_create_slab_pool(MIN_IOS, _crypt_io_pool); if (!cc->io_pool) { ti->error = "Cannot allocate crypt io mempool"; - goto bad3; + goto bad_slab_pool; } cc->dmreq_start = sizeof(struct ablkcipher_request); @@ -1022,7 +1022,7 @@ static int crypt_ctr(struct dm_target *t cc->page_pool = mempool_create_page_pool(MIN_POOL_PAGES, 0); if (!cc->page_pool) { ti->error = "Cannot allocate page mempool"; - goto bad4; + goto bad_page_pool; } cc->bs = bioset_create(MIN_IOS, MIN_IOS); @@ -1033,25 +1033,25 @@ static int crypt_ctr(struct dm_target *t if (crypto_ablkcipher_setkey(tfm, cc->key, key_size) < 0) { ti->error = "Error setting key"; - goto bad5; + goto bad_device; } if (sscanf(argv[2], "%llu", &tmpll) != 1) { ti->error = "Invalid iv_offset sector"; - goto bad5; + goto bad_device; } cc->iv_offset = tmpll; if (sscanf(argv[4], "%llu", &tmpll) != 1) { ti->error = "Invalid device sector"; - goto bad5; + goto bad_device; } cc->start = tmpll; if (dm_get_device(ti, argv[3], cc->start, ti->len, dm_table_get_mode(ti->table), &cc->dev)) { ti->error = "Device lookup failed"; - goto bad5; + goto bad_device; } if (ivmode && cc->iv_gen_ops) { @@ -1060,7 +1060,7 @@ static int crypt_ctr(struct dm_target *t cc->iv_mode = kmalloc(strlen(ivmode) + 1, GFP_KERNEL); if (!cc->iv_mode) { ti->error = "Error kmallocing iv_mode string"; - goto bad_iv_mode; + goto bad_ivmode_string; } strcpy(cc->iv_mode, ivmode); } else @@ -1085,22 +1085,22 @@ bad_crypt_queue: destroy_workqueue(cc->io_queue); bad_io_queue: kfree(cc->iv_mode); -bad_iv_mode: +bad_ivmode_string: dm_put_device(ti, cc->dev); -bad5: +bad_device: bioset_free(cc->bs); bad_bs: mempool_destroy(cc->page_pool); -bad4: +bad_page_pool: mempool_destroy(cc->req_pool); bad_req_pool: mempool_destroy(cc->io_pool); -bad3: +bad_slab_pool: if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) cc->iv_gen_ops->dtr(cc); -bad2: +bad_ivmode: crypto_free_ablkcipher(tfm); -bad1: +bad_cipher: /* Must zero key material before freeing */ memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8)); kfree(cc);