cryptodev_hash_init is concerned mostly with allocating data structures
for hash operations.
This patch replaces the call it makes to crypto_ahash_init with
one to cryptodev_hash_reset to avoid code duplication. This call is made
now outside of the original function to increase modularity.

Signed-off-by: Cristian Stoica <cristian.sto...@nxp.com>
---
Respin with corrected context

 cryptlib.c | 9 ---------
 ioctl.c    | 5 +++++
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/cryptlib.c b/cryptlib.c
index 44ce763..e5c4530 100644
--- a/cryptlib.c
+++ b/cryptlib.c
@@ -370,18 +370,9 @@ int cryptodev_hash_init(struct hash_data *hdata, const 
char *alg_name,
        ahash_request_set_callback(hdata->async.request,
                        CRYPTO_TFM_REQ_MAY_BACKLOG,
                        cryptodev_complete, hdata->async.result);
-
-       ret = crypto_ahash_init(hdata->async.request);
-       if (unlikely(ret)) {
-               derr(0, "error in crypto_hash_init()");
-               goto error_request;
-       }
-
        hdata->init = 1;
        return 0;
 
-error_request:
-       ahash_request_free(hdata->async.request);
 error:
        kfree(hdata->async.result);
        crypto_free_ahash(hdata->async.s);
diff --git a/ioctl.c b/ioctl.c
index c781f9d..c2b8754 100644
--- a/ioctl.c
+++ b/ioctl.c
@@ -278,6 +278,11 @@ crypto_create_session(struct fcrypt *fcr, struct 
session_op *sop)
                        ret = -EINVAL;
                        goto session_error;
                }
+
+               ret = cryptodev_hash_reset(&ses_new->hdata);
+               if (ret != 0) {
+                       goto session_error;
+               }
        }
 
        ses_new->alignmask = max(ses_new->cdata.alignmask,
-- 
2.4.10


_______________________________________________
Cryptodev-linux-devel mailing list
Cryptodev-linux-devel@gna.org
https://mail.gna.org/listinfo/cryptodev-linux-devel

Reply via email to