1 Star 0 Fork 28

xh/kmod

forked from src-openEuler/kmod 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-libkmod-kmod_builtin_get_modinfo-free-modinfo-on-err.patch 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
From 47807c4cfa5ffe1e5da27e3d3056d9b47ba998c5 Mon Sep 17 00:00:00 2001
From: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Date: Sun, 29 Nov 2020 18:47:35 +0200
Subject: [PATCH] libkmod: kmod_builtin_get_modinfo: free modinfo on error
reason:kmod_builtin_get_modinfo: free modinfo on error
Conflict:NA
Reference:https://lore.kernel.org/linux-modules/CAKi4VA+kaWfLZ_Ue-teaJAvDQjfM6G-WK3KmMWVinR-Zg6T64A@mail.gmail.com/T/#t
The function allocates array but on building it if get_string()
fails it returns the error leaving the array allocated. The caller
does not care about it in error case either.
Free it to fix memory leak.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
---
libkmod/libkmod-builtin.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libkmod/libkmod-builtin.c b/libkmod/libkmod-builtin.c
index aaec5dd..fc9a376 100644
--- a/libkmod/libkmod-builtin.c
+++ b/libkmod/libkmod-builtin.c
@@ -314,6 +314,7 @@ ssize_t kmod_builtin_get_modinfo(struct kmod_ctx *ctx, const char *modname,
offset = get_string(iter, pos, &line, &linesz);
if (offset <= 0) {
count = (offset) ? -errno : -EOF;
+ free(*modinfo);
goto fail;
}
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xinghe_1/kmod.git
git@gitee.com:xinghe_1/kmod.git
xinghe_1
kmod
kmod
master

搜索帮助