mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
[CRYPTO] api: fix crypto_alloc_base() return value
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>
This commit is contained in:
parent
53a5fbdc2d
commit
9765d262b8
1 changed files with 8 additions and 7 deletions
15
crypto/api.c
15
crypto/api.c
|
@ -331,7 +331,7 @@ struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 flags)
|
|||
tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, flags);
|
||||
tfm = kzalloc(tfm_size, GFP_KERNEL);
|
||||
if (tfm == NULL)
|
||||
goto out;
|
||||
goto out_err;
|
||||
|
||||
tfm->__crt_alg = alg;
|
||||
|
||||
|
@ -355,6 +355,7 @@ struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 flags)
|
|||
crypto_exit_ops(tfm);
|
||||
out_free_tfm:
|
||||
kfree(tfm);
|
||||
out_err:
|
||||
tfm = ERR_PTR(err);
|
||||
out:
|
||||
return tfm;
|
||||
|
@ -414,14 +415,14 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 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);
|
||||
goto err;
|
||||
}
|
||||
|
||||
tfm = __crypto_alloc_tfm(alg, 0);
|
||||
if (!IS_ERR(tfm))
|
||||
break;
|
||||
return tfm;
|
||||
|
||||
crypto_mod_put(alg);
|
||||
err = PTR_ERR(tfm);
|
||||
|
@ -433,9 +434,9 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
|
|||
err = -EINTR;
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return tfm;
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_alloc_base);
|
||||
|
||||
|
|
Loading…
Reference in a new issue