1 Star 0 Fork 10

大鱼/sysfsutils

forked from src-openEuler/sysfsutils 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0002-lib-Fixed-memory-leaks-in-lib-sysfs_device.c.patch 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
From e2267a5def65380db738e434da4a3920e6136f95 Mon Sep 17 00:00:00 2001
From: Chris White <[email protected]>
Date: Fri, 25 Jun 2021 17:55:00 +0000
Subject: [PATCH] lib: Fixed memory leaks in lib/sysfs_device.c
- sysfs_open_device_tree() has two case where the function returns
before the devlist pointer is closed.
Warned-by: covscan
Signed-off-by: Chris White <[email protected]>
---
lib/sysfs_device.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/sysfs_device.c b/lib/sysfs_device.c
index 5f815f9..78ed48e 100644
--- a/lib/sysfs_device.c
+++ b/lib/sysfs_device.c
@@ -247,6 +247,7 @@ struct sysfs_device *sysfs_open_device_tree(const char *path)
if (new == NULL) {
dbg_printf("Error opening device tree at %s\n",
cur->path);
+ sysfs_close_device(devlist);
sysfs_close_device_tree(rootdev);
return NULL;
}
@@ -257,7 +258,7 @@ struct sysfs_device *sysfs_open_device_tree(const char *path)
dlist_unshift_sorted(rootdev->children, new, sort_list);
}
}
-
+ sysfs_close_device(devlist);
return rootdev;
}
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hourenyu/sysfsutils.git
[email protected]:hourenyu/sysfsutils.git
hourenyu
sysfsutils
sysfsutils
master

搜索帮助