From 8467c72f2f49d6b762a0bc3b8286bbde3a6c619b Mon Sep 17 00:00:00 2001 From: Mao Jinlong Date: Tue, 14 Jul 2020 22:24:40 +0800 Subject: [PATCH] coresight: Delete path from active paths when exception happens The path will be released when fail to enable any sink or link. The path must be deleted from active paths before release it. Otherwise it will get invalid address of path when enable or disable the paths. Change-Id: Id37fdbc3854bae414f043bd049bc6af2e90af5fa Signed-off-by: Mao Jinlong --- drivers/hwtracing/coresight/coresight.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index ed7cf0e87c50..788caee61736 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -905,7 +905,7 @@ static int coresight_store_path(struct list_head *path) return 0; } -static void coresight_enable_source_link(struct list_head *path) +static int coresight_enable_source_link(struct list_head *path) { u32 type; int ret; @@ -951,10 +951,10 @@ static void coresight_enable_source_link(struct list_head *path) } } - return; + return 0; err: coresight_disable_path_from(path, nd); - coresight_release_path(path); + return ret; } static void coresight_disable_source_link(struct list_head *path) @@ -1012,13 +1012,22 @@ void coresight_disable_all_source_link(void) void coresight_enable_all_source_link(void) { + struct list_head *path = NULL; struct coresight_path *cspath = NULL; struct coresight_path *cspath_next = NULL; + int ret; + mutex_lock(&coresight_mutex); list_for_each_entry_safe(cspath, cspath_next, &cs_active_paths, link) { - coresight_enable_source_link(cspath->path); + ret = coresight_enable_source_link(cspath->path); + if (ret) { + path = cspath->path; + list_del(&cspath->link); + kfree(cspath); + coresight_release_path(path); + } } if (activated_sink && activated_sink->enable)