!33 [sync] PR-32: backport community patches to fix mem leak in sysfs_attr.c, sysfs_device.c, and sysfs_driver.c
From: @openeuler-sync-bot Reviewed-by: @swf504 Signed-off-by: @swf504
This commit is contained in:
commit
985230adae
29
0010-lib-Fixed-a-memory-leak-in-lib-sysfs_driver.c.patch
Normal file
29
0010-lib-Fixed-a-memory-leak-in-lib-sysfs_driver.c.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From 5777dc78d306f7b0ab407d666f8c9537bd8535fe Mon Sep 17 00:00:00 2001
|
||||
From: Chris White <chwhite@redhat.com>
|
||||
Date: Fri, 25 Jun 2021 18:00:25 +0000
|
||||
Subject: [PATCH] lib: Fixed a memory leak in lib/sysfs_driver.c
|
||||
|
||||
- sysfs_get_driver_devices() had a case where the function returned
|
||||
before the dev pointer was closed.
|
||||
|
||||
Warned-by: covscan
|
||||
Signed-off-by: Chris White <chwhite@redhat.com>
|
||||
---
|
||||
lib/sysfs_driver.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/lib/sysfs_driver.c b/lib/sysfs_driver.c
|
||||
index a0b9dd5..13c33cf 100644
|
||||
--- a/lib/sysfs_driver.c
|
||||
+++ b/lib/sysfs_driver.c
|
||||
@@ -252,6 +252,7 @@ struct dlist *sysfs_get_driver_devices(struct sysfs_driver *drv)
|
||||
if (!drv->devices) {
|
||||
dprintf("Error creating device list\n");
|
||||
sysfs_close_list(linklist);
|
||||
+ sysfs_close_device(dev);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
--
|
||||
2.27.0
|
||||
|
||||
38
0011-lib-Fixed-memory-leaks-in-lib-sysfs_device.c.patch
Normal file
38
0011-lib-Fixed-memory-leaks-in-lib-sysfs_device.c.patch
Normal file
@ -0,0 +1,38 @@
|
||||
From e2267a5def65380db738e434da4a3920e6136f95 Mon Sep 17 00:00:00 2001
|
||||
From: Chris White <chwhite@redhat.com>
|
||||
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 <chwhite@redhat.com>
|
||||
---
|
||||
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) {
|
||||
dprintf("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
|
||||
|
||||
62
0012-lib-Fixed-memory-leaks-in-lib-sysfs_attr.c.patch
Normal file
62
0012-lib-Fixed-memory-leaks-in-lib-sysfs_attr.c.patch
Normal file
@ -0,0 +1,62 @@
|
||||
From 9a4aac68658a61df1c97ecdd7d9a9e67f572fb3e Mon Sep 17 00:00:00 2001
|
||||
From: Chris White <chwhite@redhat.com>
|
||||
Date: Fri, 25 Jun 2021 17:32:10 +0000
|
||||
Subject: [PATCH] lib: Fixed memory leaks in lib/sysfs_attr.c
|
||||
|
||||
- read_dir_links() has a case where the function returns before
|
||||
closing the dir pointer.
|
||||
|
||||
- sysfs_read_dir_subdirs() has a case where the function returns
|
||||
before closing the dev pointer.
|
||||
|
||||
- read_dir_subdirs() has a case where the function returns before
|
||||
closing the dir pointer.
|
||||
|
||||
- get_attributes_list() has a case where the function returns before
|
||||
closing the dir pointer.
|
||||
|
||||
Warned-by: covscan
|
||||
Signed-off-by: Chris White <chwhite@redhat.com>
|
||||
---
|
||||
lib/sysfs_attr.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/lib/sysfs_attr.c b/lib/sysfs_attr.c
|
||||
index fe27dbe..82aacf4 100644
|
||||
--- a/lib/sysfs_attr.c
|
||||
+++ b/lib/sysfs_attr.c
|
||||
@@ -415,6 +415,7 @@ struct dlist *read_dir_links(const char *path)
|
||||
(SYSFS_NAME_LEN, sysfs_del_name);
|
||||
if (!linklist) {
|
||||
dprintf("Error creating list\n");
|
||||
+ closedir(dir);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -470,6 +471,7 @@ struct sysfs_device *sysfs_read_dir_subdirs(const char *path)
|
||||
dir = opendir(path);
|
||||
if (!dir) {
|
||||
dprintf("Error opening directory %s\n", path);
|
||||
+ sysfs_close_device(dev);
|
||||
return NULL;
|
||||
}
|
||||
while ((dirent = readdir(dir)) != NULL) {
|
||||
@@ -524,6 +526,7 @@ struct dlist *read_dir_subdirs(const char *path)
|
||||
(SYSFS_NAME_LEN, sysfs_del_name);
|
||||
if (!dirlist) {
|
||||
dprintf("Error creating list\n");
|
||||
+ closedir(dir);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -573,6 +576,7 @@ struct dlist *get_attributes_list(struct dlist *alist, const char *path)
|
||||
sysfs_del_attribute);
|
||||
if (!alist) {
|
||||
dprintf("Error creating list\n");
|
||||
+ closedir(dir);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: sysfsutils
|
||||
Version: 2.1.0
|
||||
Release: 33
|
||||
Release: 34
|
||||
Summary: A set of utilities for interfacing with sysfs
|
||||
License: GPLv2 and LGPLv2+
|
||||
URL: http://sourceforge.net/projects/linux-diag/
|
||||
@ -16,6 +16,9 @@ Patch6: 0006-fix-of-FUNC_TABLE_SIZE-mentioned-in-prev-commit.patch
|
||||
Patch7: 0007-Fix-compiler-complain-about-multiple-defs-of-my_stdo.patch
|
||||
Patch8: 0008-Use-stat-not-lstat-to-find-link-target.patch
|
||||
Patch9: 0009-path_is_file-should-call-stat-not-lstat.patch
|
||||
Patch10: 0010-lib-Fixed-a-memory-leak-in-lib-sysfs_driver.c.patch
|
||||
Patch11: 0011-lib-Fixed-memory-leaks-in-lib-sysfs_device.c.patch
|
||||
Patch12: 0012-lib-Fixed-memory-leaks-in-lib-sysfs_attr.c.patch
|
||||
|
||||
BuildRequires: gcc chrpath
|
||||
Provides: libsysfs libsysfs%{?_isa}
|
||||
@ -88,6 +91,9 @@ chrpath -d $(find $RPM_BUILD_ROOT -name systool)
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon May 8 2023 Jiangtian Feng <fengjiangtian@huawei.com> - 2.1.0-34
|
||||
- backport community patches to fix mem leak in sysfs_attr.c, sysfs_device.c, and sysfs_driver.c
|
||||
|
||||
* Wed Mar 30 2022 yanglongkang <yanglongkang@h-partners.com> - 2.1.0-33
|
||||
- correcting errors in 0009-path_is_file-should-call-stat-not-lstat.patch
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user