diff options
-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 2e84d4b54790..4fb7fa45cb0d 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 | ||