This patch makes crypto_alloc_base() return proper return value.
- If kzalloc() failure happens within __crypto_alloc_tfm(),
crypto_alloc_base() returns NULL. But crypto_alloc_base()
is supposed to return error code as pointer. So this patch
makes it return -ENOMEM in that case.
- crypto_alloc_base() is suppose to return -EINTR, if it is
interrupted by signal. But it may not return -EINTR.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, flags);
tfm = kzalloc(tfm_size, GFP_KERNEL);
if (tfm == NULL)
tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, flags);
tfm = kzalloc(tfm_size, GFP_KERNEL);
if (tfm == NULL)
crypto_exit_ops(tfm);
out_free_tfm:
kfree(tfm);
crypto_exit_ops(tfm);
out_free_tfm:
kfree(tfm);
tfm = ERR_PTR(err);
out:
return tfm;
tfm = ERR_PTR(err);
out:
return tfm;
struct crypto_alg *alg;
alg = crypto_alg_mod_lookup(alg_name, type, mask);
struct crypto_alg *alg;
alg = crypto_alg_mod_lookup(alg_name, type, mask);
- err = PTR_ERR(alg);
- tfm = ERR_PTR(err);
- if (IS_ERR(alg))
+ if (IS_ERR(alg)) {
+ err = PTR_ERR(alg);
tfm = __crypto_alloc_tfm(alg, 0);
if (!IS_ERR(tfm))
tfm = __crypto_alloc_tfm(alg, 0);
if (!IS_ERR(tfm))
crypto_mod_put(alg);
err = PTR_ERR(tfm);
crypto_mod_put(alg);
err = PTR_ERR(tfm);
}
EXPORT_SYMBOL_GPL(crypto_alloc_base);
}
EXPORT_SYMBOL_GPL(crypto_alloc_base);