summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-07-09 06:26:48 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2010-07-19 09:21:25 +0200
commit488c0d60ca3a86176b1a263630701a641b608eb6 (patch)
tree49fb58aedc599227454c6dc6ec6a52db36e4df1b
parent15f3c611f8d31cc0fc973481ffa3aec420ed004a (diff)
downloadcryptodev-linux-488c0d60ca3a86176b1a263630701a641b608eb6.tar.gz
cryptodev-linux-488c0d60ca3a86176b1a263630701a641b608eb6.tar.xz
cryptodev-linux-488c0d60ca3a86176b1a263630701a641b608eb6.zip
Fix cipher_data deinitialization.
Guard crypto API *free* with "if (ptr)"; it works without the guards, but that seems to be an implementation detail - at least in the case of crypto_ablkcipher. Free them in the opposite order of allocation, async.request points to async.result and async.s.
-rw-r--r--cryptodev_cipher.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/cryptodev_cipher.c b/cryptodev_cipher.c
index 3ec5cd5..7777e6e 100644
--- a/cryptodev_cipher.c
+++ b/cryptodev_cipher.c
@@ -111,9 +111,11 @@ int cryptodev_cipher_init(struct cipher_data* out, const char* alg_name, uint8_t
return 0;
error:
- crypto_free_ablkcipher(out->async.s);
+ if (out->async.request)
+ ablkcipher_request_free(out->async.request);
kfree(out->async.result);
- ablkcipher_request_free(out->async.request);
+ if (out->async.s)
+ crypto_free_ablkcipher(out->async.s);
return ret;
}
@@ -121,9 +123,11 @@ error:
void cryptodev_cipher_deinit(struct cipher_data* cdata)
{
if (cdata->init) {
- crypto_free_ablkcipher(cdata->async.s);
+ if (cdata->async.request)
+ ablkcipher_request_free(cdata->async.request);
kfree(cdata->async.result);
- ablkcipher_request_free(cdata->async.request);
+ if (cdata->async.s)
+ crypto_free_ablkcipher(cdata->async.s);
cdata->init = 0;
}