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
59
60
61
62
63
64
65
66
67
68
69
70
|
From 3e3996b40fd3a93cbe2e5ddee244280dd7de6c18 Mon Sep 17 00:00:00 2001
From: Cristian Stoica <cristian.stoica@freescale.com>
Date: Tue, 9 Feb 2016 21:07:06 +0200
Subject: [PATCH 39/40] fix memory leaks on error path for CIOCHASH
Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
---
ioctl.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/ioctl.c b/ioctl.c
index ff3de44..8d81b56 100644
--- a/ioctl.c
+++ b/ioctl.c
@@ -1190,18 +1190,17 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_)
ret = hash_run(&khop);
if (unlikely(ret)) {
dwarning(1, "Error in hash run");
- return ret;
+ goto hash_err;
}
ret = copy_to_user(khop.hash_op.mac_result, khop.hash_output, khop.digestsize);
if (unlikely(ret)) {
dwarning(1, "Error in copy to user");
- return ret;
}
- /* put session */
+ hash_err:
hash_destroy_session(khop.hash_op.ses);
- return 0;
+ return ret;
case CIOCAUTHCRYPT:
if (unlikely(ret = kcaop_from_user(&kcaop, fcr, arg))) {
dwarning(1, "Error copying from user");
@@ -1532,22 +1531,25 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_)
ret = hash_run(&khop);
if (unlikely(ret)) {
dwarning(1, "Error in hash run");
- return ret;
+ goto hash_err;
}
ret = copy_to_user(khop.hash_op.mac_result, khop.hash_output,
khop.digestsize);
if (unlikely(ret)) {
dwarning(1, "Error in copy to user");
- return ret;
+ goto hash_err;
}
- copy_to_user(arg, &compat_hash_op_data,
+ ret = copy_to_user(arg, &compat_hash_op_data,
sizeof(struct compat_hash_op_data));
+ if (unlikely(ret)) {
+ dwarning(1, "Error in copy to user");
+ }
- /* put session */
+ hash_err:
hash_destroy_session(khop.hash_op.ses);
- return 0;
+ return ret;
case COMPAT_CIOCAUTHCRYPT:
if (unlikely(ret = compat_kcaop_from_user(&kcaop, fcr, arg))) {
--
2.7.0
|