@@ -134,6 +134,12 @@ static struct crypto_instance *crypto_ecb_alloc(struct rtattr **tb)
if (IS_ERR(inst))
goto out_put_alg;
+ err = -ENAMETOOLONG;
+ if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME,
+ "ecb_generic(%s)", alg->cra_driver_name)
+ >= CRYPTO_MAX_ALG_NAME)
+ goto out_err;
+
inst->alg.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER;
inst->alg.cra_priority = alg->cra_priority;
inst->alg.cra_blocksize = alg->cra_blocksize;
@@ -155,6 +161,12 @@ static struct crypto_instance *crypto_ecb_alloc(struct rtattr **tb)
out_put_alg:
crypto_mod_put(alg);
return inst;
+
+out_err:
+ crypto_drop_spawn(crypto_instance_ctx(inst));
+ kfree(inst);
+ crypto_mod_put(alg);
+ return ERR_PTR(err);
}
static void crypto_ecb_free(struct crypto_instance *inst)
As ECB could potentially be wrapped by other chaining modes to operate on larger chunks of data in parallel, we would like to distinguish between the generic ECB and accelerated implementations of ECB, as using the former will not result in any speedup. Therefore, update the driver name of generic ECB to 'ecb_generic(%s)'. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- crypto/ecb.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)