Unverified Commit 800a6b44 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!1905 tracing: Fix memleak due to race between current_tracer and trace

parents 369da114 1f21924b
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -3736,8 +3736,15 @@ static void *s_start(struct seq_file *m, loff_t *pos)
	 * will point to the same string as current_trace->name.
	 */
	mutex_lock(&trace_types_lock);
	if (unlikely(tr->current_trace && iter->trace->name != tr->current_trace->name))
	if (unlikely(tr->current_trace && iter->trace->name != tr->current_trace->name)) {
		/* Close iter->trace before switching to the new current tracer */
		if (iter->trace->close)
			iter->trace->close(iter);
		*iter->trace = *tr->current_trace;
		/* Reopen the new current tracer */
		if (iter->trace->open)
			iter->trace->open(iter);
	}
	mutex_unlock(&trace_types_lock);

#ifdef CONFIG_TRACER_MAX_TRACE
+2 −1
Original line number Diff line number Diff line
@@ -231,7 +231,8 @@ static void irqsoff_trace_open(struct trace_iterator *iter)
{
	if (is_graph(iter->tr))
		graph_trace_open(iter);

	else
		iter->private = NULL;
}

static void irqsoff_trace_close(struct trace_iterator *iter)
+2 −0
Original line number Diff line number Diff line
@@ -168,6 +168,8 @@ static void wakeup_trace_open(struct trace_iterator *iter)
{
	if (is_graph(iter->tr))
		graph_trace_open(iter);
	else
		iter->private = NULL;
}

static void wakeup_trace_close(struct trace_iterator *iter)