lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20210701125853.710636-1-gushengxian507419@gmail.com>
Date:   Thu,  1 Jul 2021 05:58:53 -0700
From:   gushengxian <gushengxian507419@...il.com>
To:     linux-kernel@...r.kernel.org
Cc:     gushengxian <gushengxian@...ong.com>
Subject: [PATCH] tools lib traceevent: avoid memory leak: buf

From: gushengxian <gushengxian@...ong.com>

buf is realloced so free(buf) should be added to avoid memory leak.

Signed-off-by: gushengxian <gushengxian@...ong.com>
---
 tools/lib/traceevent/trace-seq.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c
index 8d5ecd2bf877..deafb773087e 100644
--- a/tools/lib/traceevent/trace-seq.c
+++ b/tools/lib/traceevent/trace-seq.c
@@ -87,11 +87,13 @@ static void expand_buffer(struct trace_seq *s)
 	buf = realloc(s->buffer, s->buffer_size + TRACE_SEQ_BUF_SIZE);
 	if (WARN_ONCE(!buf, "Can't allocate trace_seq buffer memory")) {
 		s->state = TRACE_SEQ__MEM_ALLOC_FAILED;
+		free(buf);
 		return;
 	}
 
 	s->buffer = buf;
 	s->buffer_size += TRACE_SEQ_BUF_SIZE;
+	free(buf);
 }
 
 /**
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ