diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2006-10-11 08:29:51 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2006-10-11 08:29:51 -0400 |
commit | 9765d262b8230b735c4b2815b041c09a00833cf1 (patch) | |
tree | cf24840b4e1f06f1f1f756f52f4f9870b02a5ed3 /crypto | |
parent | 53a5fbdc2dff55161a206ed1a1385a8fa8055c34 (diff) |
[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>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/api.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/crypto/api.c b/crypto/api.c index 2e84d4b5479..4fb7fa45cb0 100644 --- a/crypto/api.c +++ b/crypto/api.c | |||
@@ -331,7 +331,7 @@ struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 flags) | |||
331 | tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, flags); | 331 | tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, flags); |
332 | tfm = kzalloc(tfm_size, GFP_KERNEL); | 332 | tfm = kzalloc(tfm_size, GFP_KERNEL); |
333 | if (tfm == NULL) | 333 | if (tfm == NULL) |
334 | goto out; | 334 | goto out_err; |
335 | 335 | ||
336 | tfm->__crt_alg = alg; | 336 | tfm->__crt_alg = alg; |
337 | 337 | ||
@@ -355,6 +355,7 @@ cra_init_failed: | |||
355 | crypto_exit_ops(tfm); | 355 | crypto_exit_ops(tfm); |
356 | out_free_tfm: | 356 | out_free_tfm: |
357 | kfree(tfm); | 357 | kfree(tfm); |
358 | out_err: | ||
358 | tfm = ERR_PTR(err); | 359 | tfm = ERR_PTR(err); |
359 | out: | 360 | out: |
360 | return tfm; | 361 | return tfm; |
@@ -414,14 +415,14 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask) | |||
414 | struct crypto_alg *alg; | 415 | struct crypto_alg *alg; |
415 | 416 | ||
416 | alg = crypto_alg_mod_lookup(alg_name, type, mask); | 417 | alg = crypto_alg_mod_lookup(alg_name, type, mask); |
417 | err = PTR_ERR(alg); | 418 | if (IS_ERR(alg)) { |
418 | tfm = ERR_PTR(err); | 419 | err = PTR_ERR(alg); |
419 | if (IS_ERR(alg)) | ||
420 | goto err; | 420 | goto err; |
421 | } | ||
421 | 422 | ||
422 | tfm = __crypto_alloc_tfm(alg, 0); | 423 | tfm = __crypto_alloc_tfm(alg, 0); |
423 | if (!IS_ERR(tfm)) | 424 | if (!IS_ERR(tfm)) |
424 | break; | 425 | return tfm; |
425 | 426 | ||
426 | crypto_mod_put(alg); | 427 | crypto_mod_put(alg); |
427 | err = PTR_ERR(tfm); | 428 | err = PTR_ERR(tfm); |
@@ -433,9 +434,9 @@ err: | |||
433 | err = -EINTR; | 434 | err = -EINTR; |
434 | break; | 435 | break; |
435 | } | 436 | } |
436 | }; | 437 | } |
437 | 438 | ||
438 | return tfm; | 439 | return ERR_PTR(err); |
439 | } | 440 | } |
440 | EXPORT_SYMBOL_GPL(crypto_alloc_base); | 441 | EXPORT_SYMBOL_GPL(crypto_alloc_base); |
441 | 442 | ||