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]
Date:   Wed, 20 Jul 2022 10:44:25 +0800
From:   Zhiqiang Liu <liuzhiqiang26@...wei.com>
To:     <linux-kernel@...r.kernel.org>, <rostedt@...dmis.org>,
        <mingo@...hat.com>
CC:     Louhongxiang <louhongxiang@...wei.com>,
        linfeilong <linfeilong@...wei.com>
Subject: tracing: use free_trace_buffer in allocate_trace_buffers


In allocate_trace_buffers(), if allocating tr->max_buffer
fails, we can directly call free_trace_buffer to free
tr->array_buffer.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@...wei.com>
---
 kernel/trace/trace.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index b8dd54627075..883c8e9987f6 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -9101,6 +9101,16 @@ allocate_trace_buffer(struct trace_array *tr, struct array_buffer *buf, int size
        return 0;
 }

+static void free_trace_buffer(struct array_buffer *buf)
+{
+       if (buf->buffer) {
+               ring_buffer_free(buf->buffer);
+               buf->buffer = NULL;
+               free_percpu(buf->data);
+               buf->data = NULL;
+       }
+}
+
 static int allocate_trace_buffers(struct trace_array *tr, int size)
 {
        int ret;
@@ -9113,10 +9123,7 @@ static int allocate_trace_buffers(struct trace_array *tr, int size)
        ret = allocate_trace_buffer(tr, &tr->max_buffer,
                                    allocate_snapshot ? size : 1);
        if (MEM_FAIL(ret, "Failed to allocate trace buffer\n")) {
-               ring_buffer_free(tr->array_buffer.buffer);
-               tr->array_buffer.buffer = NULL;
-               free_percpu(tr->array_buffer.data);
-               tr->array_buffer.data = NULL;
+               free_trace_buffer(&tr->array_buffer);
                return -ENOMEM;
        }
        tr->allocated_snapshot = allocate_snapshot;
@@ -9131,16 +9138,6 @@ static int allocate_trace_buffers(struct trace_array *tr, int size)
        return 0;
 }

-static void free_trace_buffer(struct array_buffer *buf)
-{
-       if (buf->buffer) {
-               ring_buffer_free(buf->buffer);
-               buf->buffer = NULL;
-               free_percpu(buf->data);
-               buf->data = NULL;
-       }
-}
-
 static void free_trace_buffers(struct trace_array *tr)
 {
        if (!tr)
--
2.33.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ