1 Star 0 Fork 32

compile_success/gazelle_3

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0128-fix-t_params-double-free.patch 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
yinbin6 提交于 2024-02-04 15:21 . sync patches from upstream
From 8905d508d754a6d75516bbf26839848f4dfef282 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Mon, 29 Jan 2024 19:11:45 +0800
Subject: [PATCH] fix t_params double free
---
src/lstack/core/lstack_protocol_stack.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index 800872b..bb7ec17 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -660,7 +660,7 @@ int32_t stack_setup_thread(void)
for (uint32_t i = 0; i < queue_num; ++i) {
t_params[i] = malloc(sizeof(struct thread_params));
if (t_params[i] == NULL) {
- goto OUT;
+ goto OUT1;
}
}
@@ -669,18 +669,18 @@ int32_t stack_setup_thread(void)
if (i % 2 == 0) {
ret = sprintf_s(name, sizeof(name), "%s_%d_%d", LSTACK_RECV_THREAD_NAME, process_index, i / 2);
if (ret < 0) {
- goto OUT;
+ goto OUT1;
}
} else {
ret = sprintf_s(name, sizeof(name), "%s_%d_%d", LSTACK_SEND_THREAD_NAME, process_index, i / 2);
if (ret < 0) {
- goto OUT;
+ goto OUT1;
}
}
} else {
ret = sprintf_s(name, sizeof(name), "%s", LSTACK_THREAD_NAME);
if (ret < 0) {
- goto OUT;
+ goto OUT1;
}
}
@@ -689,24 +689,26 @@ int32_t stack_setup_thread(void)
ret = create_thread((void *)t_params[i], name, gazelle_stack_thread);
if (ret != 0) {
- goto OUT;
+ goto OUT1;
}
}
/* 2: wait stack thread and kernel_event thread init finish */
wait_sem_value(&g_stack_group.sem_stack_setup, queue_num * 2);
if (g_stack_group.stack_setup_fail) {
- goto OUT;
+ /* t_params free by stack thread */
+ goto OUT2;
}
g_stack_group.stack_num = queue_num;
return 0;
-OUT:
+OUT1:
for (int32_t i = 0; i < queue_num; ++i) {
if (t_params[i] != NULL) {
free(t_params[i]);
}
}
+OUT2:
return -1;
}
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/compile_success/gazelle_3.git
git@gitee.com:compile_success/gazelle_3.git
compile_success
gazelle_3
gazelle_3
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385