blob: 83d9005a06e7408c72f2128e960ed946dc87184c [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From c2bf0e42b1d9fda60cde4a3a682784d349ef1c0b Mon Sep 17 00:00:00 2001
2From: Cristian Stoica <cristian.stoica@nxp.com>
3Date: Thu, 4 May 2017 15:06:21 +0300
4Subject: [PATCH 2/3] refactoring: relocate code to simplify later patches
5
6This code move will simplify the conversion to new AEAD interface in
7next patches
8
9Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
10
11Upstream-Status: Backport
12
13Commit ID: c2bf0e42b1d9fda
14
15Signed-off-by: Hongzhi.Song <hongzhi.song@windriver.com>
16---
17 authenc.c | 17 +++++++++--------
18 1 file changed, 9 insertions(+), 8 deletions(-)
19
20diff --git a/authenc.c b/authenc.c
21index 28eb0f9..95727b4 100644
22--- a/authenc.c
23+++ b/authenc.c
24@@ -711,11 +711,18 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut
25 return -ENOMEM;
26 }
27
28+ ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len,
29+ kcaop->task, kcaop->mm, &src_sg, &dst_sg);
30+ if (unlikely(ret)) {
31+ derr(1, "get_userbuf(): Error getting user pages.");
32+ goto free_auth_buf;
33+ }
34+
35 if (caop->auth_src && caop->auth_len > 0) {
36 if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) {
37 derr(1, "unable to copy auth data from userspace.");
38 ret = -EFAULT;
39- goto free_auth_buf;
40+ goto free_pages;
41 }
42
43 sg_init_one(&tmp, auth_buf, caop->auth_len);
44@@ -724,16 +731,10 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut
45 auth_sg = NULL;
46 }
47
48- ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len,
49- kcaop->task, kcaop->mm, &src_sg, &dst_sg);
50- if (unlikely(ret)) {
51- derr(1, "get_userbuf(): Error getting user pages.");
52- goto free_auth_buf;
53- }
54-
55 ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len,
56 src_sg, dst_sg, caop->len);
57
58+free_pages:
59 release_user_pages(ses_ptr);
60
61 free_auth_buf:
62--
632.11.0
64