aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-kernel/cryptodev/sdk_patches/0002-refactoring-relocate-code-to-simplify-later-patches.patch
blob: b948c914dfc7f775ca40ddd1fad8f6796a18f1df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From c2bf0e42b1d9fda60cde4a3a682784d349ef1c0b Mon Sep 17 00:00:00 2001
From: Cristian Stoica <cristian.stoica@nxp.com>
Date: Thu, 4 May 2017 15:06:21 +0300
Subject: [PATCH 2/9] refactoring: relocate code to simplify later patches

This code move will simplify the conversion to new AEAD interface in
next patches

Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
---
 authenc.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/authenc.c b/authenc.c
index 28eb0f9..95727b4 100644
--- a/authenc.c
+++ b/authenc.c
@@ -711,11 +711,18 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut
 		return -ENOMEM;
 	}
 
+	ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len,
+			kcaop->task, kcaop->mm, &src_sg, &dst_sg);
+	if (unlikely(ret)) {
+		derr(1, "get_userbuf(): Error getting user pages.");
+		goto free_auth_buf;
+	}
+
 	if (caop->auth_src && caop->auth_len > 0) {
 		if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) {
 			derr(1, "unable to copy auth data from userspace.");
 			ret = -EFAULT;
-			goto free_auth_buf;
+			goto free_pages;
 		}
 
 		sg_init_one(&tmp, auth_buf, caop->auth_len);
@@ -724,16 +731,10 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut
 		auth_sg = NULL;
 	}
 
-	ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len,
-			kcaop->task, kcaop->mm, &src_sg, &dst_sg);
-	if (unlikely(ret)) {
-		derr(1, "get_userbuf(): Error getting user pages.");
-		goto free_auth_buf;
-	}
-
 	ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len,
 			src_sg, dst_sg, caop->len);
 
+free_pages:
 	release_user_pages(ses_ptr);
 
 free_auth_buf:
-- 
2.7.4