summaryrefslogtreecommitdiffstats
path: root/recipes-connectivity/openssl/openssl-qoriq/qoriq/0024-cryptodev-do-not-cache-file-descriptor-in-open.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-connectivity/openssl/openssl-qoriq/qoriq/0024-cryptodev-do-not-cache-file-descriptor-in-open.patch')
-rw-r--r--recipes-connectivity/openssl/openssl-qoriq/qoriq/0024-cryptodev-do-not-cache-file-descriptor-in-open.patch100
1 files changed, 100 insertions, 0 deletions
diff --git a/recipes-connectivity/openssl/openssl-qoriq/qoriq/0024-cryptodev-do-not-cache-file-descriptor-in-open.patch b/recipes-connectivity/openssl/openssl-qoriq/qoriq/0024-cryptodev-do-not-cache-file-descriptor-in-open.patch
new file mode 100644
index 0000000..e798d3e
--- /dev/null
+++ b/recipes-connectivity/openssl/openssl-qoriq/qoriq/0024-cryptodev-do-not-cache-file-descriptor-in-open.patch
@@ -0,0 +1,100 @@
1From a44701abd995b3db80001d0c5d88e9ead05972c1 Mon Sep 17 00:00:00 2001
2From: Cristian Stoica <cristian.stoica@freescale.com>
3Date: Thu, 19 Feb 2015 16:43:29 +0200
4Subject: [PATCH 24/26] cryptodev: do not cache file descriptor in 'open'
5
6The file descriptor returned by get_dev_crypto is cached after a
7successful return. The issue is, it is cached inside 'open_dev_crypto'
8which is no longer useful as a general purpose open("/dev/crypto")
9function.
10
11This patch is a refactoring that moves the caching operation from
12open_dev_crypto to get_dev_crypto and leaves the former as a simpler
13function true to its name
14
15Change-Id: I980170969410381973ce75f6679a4a1401738847
16Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
17Reviewed-on: http://git.am.freescale.net:8181/34219
18---
19 crypto/engine/eng_cryptodev.c | 50 +++++++++++++++++++++----------------------
20 1 file changed, 24 insertions(+), 26 deletions(-)
21
22diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
23index dceb4f5..b74fc7c 100644
24--- a/crypto/engine/eng_cryptodev.c
25+++ b/crypto/engine/eng_cryptodev.c
26@@ -306,47 +306,45 @@ static void ctr64_inc(unsigned char *counter) {
27 if (c) return;
28 } while (n);
29 }
30-/*
31- * Return a fd if /dev/crypto seems usable, 0 otherwise.
32- */
33-static int
34-open_dev_crypto(void)
35+
36+static int open_dev_crypto(void)
37 {
38- static int fd = -1;
39+ int fd;
40
41- if (fd == -1) {
42- if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1)
43- return (-1);
44- /* close on exec */
45- if (fcntl(fd, F_SETFD, 1) == -1) {
46- close(fd);
47- fd = -1;
48- return (-1);
49- }
50+ fd = open("/dev/crypto", O_RDWR, 0);
51+ if ( fd < 0)
52+ return -1;
53+
54+ /* close on exec */
55+ if (fcntl(fd, F_SETFD, 1) == -1) {
56+ close(fd);
57+ return -1;
58 }
59- return (fd);
60+
61+ return fd;
62 }
63
64-static int
65-get_dev_crypto(void)
66+static int get_dev_crypto(void)
67 {
68- int fd, retfd;
69+ static int fd = -1;
70+ int retfd;
71
72- if ((fd = open_dev_crypto()) == -1)
73- return (-1);
74-#ifndef CRIOGET_NOT_NEEDED
75+ if (fd == -1)
76+ fd = open_dev_crypto();
77+#ifdef CRIOGET_NOT_NEEDED
78+ return fd;
79+#else
80+ if (fd == -1)
81+ return -1;
82 if (ioctl(fd, CRIOGET, &retfd) == -1)
83 return (-1);
84-
85 /* close on exec */
86 if (fcntl(retfd, F_SETFD, 1) == -1) {
87 close(retfd);
88 return (-1);
89 }
90-#else
91- retfd = fd;
92+ return retfd;
93 #endif
94- return (retfd);
95 }
96
97 static void put_dev_crypto(int fd)
98--
992.3.5
100