blob: 995fbed4eb4b1b7e5a2bda32ee2c3bb523cc056b (
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
|
From 9675e358fe73b33029a470aa5cf47527848f4054 Mon Sep 17 00:00:00 2001
From: Cristian Stoica <cristian.stoica@freescale.com>
Date: Tue, 26 Nov 2013 16:36:37 +0200
Subject: [[Patch][fsl 08/16] fix cipher algorithm memleaks
Upstream-status: Pending
Patch 67e743aef130d107c1b41e0aace7677f9ff53bd1 allocates memory for
cipher algorithm key without freeing it when session terminates. This
patch addresses the deallocation issue.
Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
Tested-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com>
---
cryptodev_int.h | 1 +
ioctl.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/cryptodev_int.h b/cryptodev_int.h
index 8d206c9..8891837 100644
--- a/cryptodev_int.h
+++ b/cryptodev_int.h
@@ -166,6 +166,7 @@ struct csession {
struct hash_data hdata;
uint32_t sid;
uint32_t alignmask;
+ uint8_t *key;
unsigned int array_size;
unsigned int used_pages; /* the number of pages that are used */
diff --git a/ioctl.c b/ioctl.c
index 18874d3..63467e0 100644
--- a/ioctl.c
+++ b/ioctl.c
@@ -235,6 +235,7 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
goto error_cipher;
key = kmalloc(keylen, GFP_KERNEL);
+ ses_new->key = key;
if (unlikely(!key)) {
ret = -ENOMEM;
goto error_cipher;
@@ -342,6 +343,7 @@ crypto_destroy_session(struct csession *ses_ptr)
ddebug(2, "freeing space for %d user pages", ses_ptr->array_size);
kfree(ses_ptr->pages);
kfree(ses_ptr->sg);
+ kfree(ses_ptr->key);
mutex_unlock(&ses_ptr->sem);
mutex_destroy(&ses_ptr->sem);
kfree(ses_ptr);
--
1.7.9.7
|