diff options
author | Miloslav Trmač <mitr@redhat.com> | 2010-07-16 19:46:11 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-19 09:30:39 +0200 |
commit | b04246828b57a14ed9f764385417219b5d3e825d (patch) | |
tree | a98687f8553f1f278a5a688247ef96d65ef53499 | |
parent | 725b85fe44a24350c64ae816da9eb3de7245006c (diff) | |
download | cryptodev-linux-b04246828b57a14ed9f764385417219b5d3e825d.tar.gz cryptodev-linux-b04246828b57a14ed9f764385417219b5d3e825d.tar.xz cryptodev-linux-b04246828b57a14ed9f764385417219b5d3e825d.zip |
Only set [ch]data->init = 1 on success.
Otherwise other members would be freed twice.
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
-rw-r--r-- | cryptodev_cipher.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/cryptodev_cipher.c b/cryptodev_cipher.c index e7d1b6d..0446a5d 100644 --- a/cryptodev_cipher.c +++ b/cryptodev_cipher.c @@ -56,8 +56,6 @@ int cryptodev_cipher_init(struct cipher_data* out, const char* alg_name, uint8_t memset(out, 0, sizeof(*out)); - out->init = 1; - out->async.s = crypto_alloc_ablkcipher(alg_name, 0, 0); if (unlikely(IS_ERR(out->async.s))) { dprintk(1,KERN_DEBUG,"%s: Failed to load cipher %s\n", __func__, @@ -109,6 +107,7 @@ int cryptodev_cipher_init(struct cipher_data* out, const char* alg_name, uint8_t ablkcipher_request_set_callback(out->async.request, CRYPTO_TFM_REQ_MAY_BACKLOG, cryptodev_complete, out->async.result); + out->init = 1; return 0; error: if (out->async.request) @@ -219,8 +218,6 @@ int cryptodev_hash_init( struct hash_data* hdata, const char* alg_name, int hmac { int ret; - hdata->init = 1; - hdata->async.s = crypto_alloc_ahash(alg_name, 0, 0); if (unlikely(IS_ERR(hdata->async.s))) { dprintk(1,KERN_DEBUG,"%s: Failed to load transform for %s\n", __func__, @@ -261,7 +258,7 @@ int ret; ahash_request_set_callback(hdata->async.request, CRYPTO_TFM_REQ_MAY_BACKLOG, cryptodev_complete, hdata->async.result); - + hdata->init = 1; return 0; error: |