[PATCH 08/25] coresight: etm: perf: Fix warning caused by etm_setup_aux failure

Mathieu Poirier mathieu.poirier at linaro.org
Mon Sep 28 12:34:56 EDT 2020

From: Tingwei Zhang <tingwei at codeaurora.org>

When coresight_build_path() fails on all the cpus, etm_setup_aux
calls etm_free_aux() to free allocated event_data.
WARN_ON(cpumask_empty(mask) will be triggered since cpu mask is empty.
Check event_data->snk_config is not NULL first to avoid this

Fixes: f5200aa9831f38 ("coresight: perf: Refactor function free_event_data()")
Signed-off-by: Tingwei Zhang <tingwei at codeaurora.org>
Reviewed-by: Mike Leach <mike.leach at linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose at arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier at linaro.org>
 drivers/hwtracing/coresight/coresight-etm-perf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index 644805e0a9ec..47894a0dcf5e 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -126,10 +126,10 @@ static void free_sink_buffer(struct etm_event_data *event_data)
 	cpumask_t *mask = &event_data->mask;
 	struct coresight_device *sink;
-	if (WARN_ON(cpumask_empty(mask)))
+	if (!event_data->snk_config)
-	if (!event_data->snk_config)
+	if (WARN_ON(cpumask_empty(mask)))
 	cpu = cpumask_first(mask);

More information about the linux-arm-kernel mailing list