Unverified Commit 4b99a7ce authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

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

parents 05340364 52ecd8d3
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -3246,8 +3246,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
@@ -222,7 +222,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
@@ -287,6 +287,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)