diff options
| author | Jesper Juhl <jj@chaosbits.net> | 2011-02-15 21:04:09 -0500 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2011-02-15 21:04:09 -0500 |
| commit | fc9044e2db8c13746cd886d6276028b27ed5c78e (patch) | |
| tree | dd5ef29162ba59ac85e2adf60b1e855123141ecb | |
| parent | 36be070ac600d023ada2ec107ee925f5ac5f902b (diff) | |
crypto: aesni-intel - Fix remaining leak in rfc4106_set_hash_key
Fix up previous patch that failed to properly fix mem leak in
rfc4106_set_hash_subkey(). This add-on patch; fixes the leak. moves
kfree() out of the error path, returns -ENOMEM rather than -EINVAL when
ablkcipher_request_alloc() fails.
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
| -rw-r--r-- | arch/x86/crypto/aesni-intel_glue.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c index e0135526345..e0e6340c8da 100644 --- a/arch/x86/crypto/aesni-intel_glue.c +++ b/arch/x86/crypto/aesni-intel_glue.c | |||
| @@ -874,19 +874,17 @@ rfc4106_set_hash_subkey(u8 *hash_subkey, const u8 *key, unsigned int key_len) | |||
| 874 | 874 | ||
| 875 | ret = crypto_ablkcipher_setkey(ctr_tfm, key, key_len); | 875 | ret = crypto_ablkcipher_setkey(ctr_tfm, key, key_len); |
| 876 | if (ret) | 876 | if (ret) |
| 877 | goto out; | 877 | goto out_free_ablkcipher; |
| 878 | 878 | ||
| 879 | ret = -ENOMEM; | ||
| 879 | req = ablkcipher_request_alloc(ctr_tfm, GFP_KERNEL); | 880 | req = ablkcipher_request_alloc(ctr_tfm, GFP_KERNEL); |
| 880 | if (!req) { | 881 | if (!req) |
| 881 | ret = -EINVAL; | ||
| 882 | goto out_free_ablkcipher; | 882 | goto out_free_ablkcipher; |
| 883 | } | ||
| 884 | 883 | ||
| 885 | req_data = kmalloc(sizeof(*req_data), GFP_KERNEL); | 884 | req_data = kmalloc(sizeof(*req_data), GFP_KERNEL); |
| 886 | if (!req_data) { | 885 | if (!req_data) |
| 887 | ret = -ENOMEM; | ||
| 888 | goto out_free_request; | 886 | goto out_free_request; |
| 889 | } | 887 | |
| 890 | memset(req_data->iv, 0, sizeof(req_data->iv)); | 888 | memset(req_data->iv, 0, sizeof(req_data->iv)); |
| 891 | 889 | ||
| 892 | /* Clear the data in the hash sub key container to zero.*/ | 890 | /* Clear the data in the hash sub key container to zero.*/ |
| @@ -911,12 +909,11 @@ rfc4106_set_hash_subkey(u8 *hash_subkey, const u8 *key, unsigned int key_len) | |||
| 911 | if (!ret) | 909 | if (!ret) |
| 912 | ret = req_data->result.err; | 910 | ret = req_data->result.err; |
| 913 | } | 911 | } |
| 912 | kfree(req_data); | ||
| 914 | out_free_request: | 913 | out_free_request: |
| 915 | ablkcipher_request_free(req); | 914 | ablkcipher_request_free(req); |
| 916 | kfree(req_data); | ||
| 917 | out_free_ablkcipher: | 915 | out_free_ablkcipher: |
| 918 | crypto_free_ablkcipher(ctr_tfm); | 916 | crypto_free_ablkcipher(ctr_tfm); |
| 919 | out: | ||
| 920 | return ret; | 917 | return ret; |
| 921 | } | 918 | } |
| 922 | 919 | ||
