From bb09e342c186f111600e763ca7a5bfb8713df6f7 Mon Sep 17 00:00:00 2001 From: Wenkai Lin Date: Wed, 12 Jan 2022 09:44:57 +0800 Subject: [PATCH 42/53] uadk: fix for resources are repeatedly released Segment fault occur when environment resources are repeatedly released, so add pointer check for wd_free_ctx and wd_free_env and clear dirty global Variables. Signed-off-by: Wenkai Lin --- wd_util.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wd_util.c b/wd_util.c index c2c109c..6cae768 100644 --- a/wd_util.c +++ b/wd_util.c @@ -825,6 +825,9 @@ static void wd_free_env(struct wd_env_config *config) struct wd_env_config_per_numa *config_numa; int i, j; + if (!config->config_per_numa) + return; + FOREACH_NUMA(i, config, config_numa) { if (!config_numa->ctx_table) continue; @@ -1010,6 +1013,9 @@ err_free_ctx_config: static void wd_free_ctx(struct wd_ctx_config *ctx_config) { + if (!ctx_config) + return; + wd_put_wd_ctx(ctx_config, ctx_config->ctx_num); free(ctx_config->ctxs); free(ctx_config); @@ -1451,6 +1457,7 @@ err_uninit_sched: } err_uninit_ctx: wd_free_ctx(config->ctx_config); + config->ctx_config = NULL; return ret; } -- 2.25.1