summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorHyung Taek Ryoo <hryoo@nvidia.com>2014-03-05 13:42:45 -0800
committerBharat Nihalani <bnihalani@nvidia.com>2014-03-12 20:54:13 -0700
commita6e8417678fc52d4046d9a9bd31d005abb9e510e (patch)
treea45d280f50063421971764c670d47336cfb7e7b6 /security
parent4e0f5aa405a09a58b3c28a0e3c73f468fecd8ef2 (diff)
security: tlk_driver: fix memory leak from tlk logging
This change to fix memory leak from tlk logging. Bug 1467162 Change-Id: I81d520ed4637861cbaab3bd7dcda063ecce9a123 Signed-off-by: Hyung Taek Ryoo <hryoo@nvidia.com> Reviewed-on: http://git-master/r/378071 (cherry picked from commit 50810a36bf0726c3df7f3d25f886e9852d43e13b) Reviewed-on: http://git-master/r/380740 Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'security')
-rw-r--r--security/tlk_driver/ote_log.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/security/tlk_driver/ote_log.c b/security/tlk_driver/ote_log.c
index 0a1fbd79b617..9a70077dbe7b 100644
--- a/security/tlk_driver/ote_log.c
+++ b/security/tlk_driver/ote_log.c
@@ -128,12 +128,13 @@ void ote_print_logs(void)
{
char *text = NULL;
char *temp = NULL;
+ char *buffer = NULL;
if (!ote_logging_enabled)
return;
- text = kzalloc(LOGBUF_SIZE, GFP_KERNEL);
- BUG_ON(!text);
+ buffer = kzalloc(LOGBUF_SIZE, GFP_KERNEL);
+ BUG_ON(!buffer);
/* This detects if the buffer proved to be too small to hold the data.
* If buffer is not large enough, it overwrites it's oldest data,
@@ -144,12 +145,17 @@ void ote_print_logs(void)
cb->overflow = 0;
}
- if (circ_buf_copy(cb, text) != 0) {
- kfree(text);
+ if (circ_buf_copy(cb, buffer) != 0) {
+ kfree(buffer);
return;
}
cb->buf[cb->end] = '\0';
+ /* In case no delimiter was found,
+ * the token is taken to be the entire string *stringp,
+ * and *stringp is made NULL.
+ */
+ text = buffer;
temp = strsep(&text, "\n");
while (temp != NULL) {
if (strnlen(temp, LOGBUF_SIZE))
@@ -159,7 +165,7 @@ void ote_print_logs(void)
/* Indicate that buffer is empty */
cb->start = cb->end;
- kfree(text);
+ kfree(buffer);
}
#else
void ote_print_logs(void) {}