1 Star 0 Fork 28

markeryang/kmod

forked from src-openEuler/kmod 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-depmod-output_builtin_alias_bin-free-idx-on-error-pa.patch 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
From bd96d05256db2ff9a89dbe2e8bb6e26fcb800052 Mon Sep 17 00:00:00 2001
From: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Date: Sun, 29 Nov 2020 18:47:36 +0200
Subject: [PATCH] depmod: output_builtin_alias_bin: free idx on error path
reason:depmod: output_builtin_alias_bin free idx on error path
Conflict:NA
Reference:https://lore.kernel.org/linux-modules/20201129164737.135866-2-yauheni.kaliuta@redhat.com/T/#u
idx is allocated in the beginning but it's not freed if there is
a failure after the allocation.
Change the error path: return immediately if idx allocation fails
and then free it in both success and error path at the end.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
---
tools/depmod.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/tools/depmod.c b/tools/depmod.c
index 875e314..2c03dfe 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2412,10 +2412,8 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
return 0;
idx = index_create();
- if (idx == NULL) {
- ret = -ENOMEM;
- goto fail;
- }
+ if (idx == NULL)
+ return -ENOMEM;
ret = kmod_module_get_builtin(depmod->ctx, &builtin);
if (ret < 0) {
@@ -2458,13 +2456,12 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
if (count)
index_write(idx, out);
-
- index_destroy(idx);
-
fail:
if (builtin)
kmod_module_unref_list(builtin);
+ index_destroy(idx);
+
return ret;
}
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/markeryang/kmod.git
git@gitee.com:markeryang/kmod.git
markeryang
kmod
kmod
master

搜索帮助