From 488c0d60ca3a86176b1a263630701a641b608eb6 Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Fri, 9 Jul 2010 06:26:48 +0200 Subject: 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. --- cryptodev_cipher.c | 12 ++++++++---- 1 file 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; } -- cgit