backport community patches to fix mem leak in lib/sysfs_device.c and lib/sysfs_attr.c
Signed-off-by: Jiangtian Feng <fengjiangtian@huawei.com>
This commit is contained in:
parent
f36c5b93d4
commit
542323c36e
38
0002-lib-Fixed-memory-leaks-in-lib-sysfs_device.c.patch
Normal file
38
0002-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) {
|
||||
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
|
||||
|
||||
62
0003-lib-Fixed-memory-leaks-in-lib-sysfs_attr.c.patch
Normal file
62
0003-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) {
|
||||
dbg_printf("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) {
|
||||
dbg_printf("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) {
|
||||
dbg_printf("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) {
|
||||
dbg_printf("Error creating list\n");
|
||||
+ closedir(dir);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: sysfsutils
|
||||
Version: 2.1.1
|
||||
Release: 2
|
||||
Release: 3
|
||||
Summary: A set of utilities for interfacing with sysfs
|
||||
License: GPLv2 and LGPLv2+
|
||||
URL: https://github.com/linux-ras/sysfsutils
|
||||
@ -8,6 +8,8 @@ URL: https://github.com/linux-ras/sysfsutils
|
||||
Source0: https://github.com/linux-ras/sysfsutils/archive/v%{version}.tar.gz
|
||||
|
||||
Patch1: 0001-lib-Fixed-a-memory-leak-in-lib-sysfs_driver.patch
|
||||
Patch2: 0002-lib-Fixed-memory-leaks-in-lib-sysfs_device.c.patch
|
||||
Patch3: 0003-lib-Fixed-memory-leaks-in-lib-sysfs_attr.c.patch
|
||||
|
||||
BuildRequires: gcc chrpath autoconf automake make libtool
|
||||
Provides: libsysfs libsysfs%{?_isa}
|
||||
@ -81,6 +83,9 @@ chrpath -d $(find $RPM_BUILD_ROOT -name systool)
|
||||
|
||||
|
||||
%changelog
|
||||
* Sat May 6 2023 Jiangtian Feng <fengjiangtian@huawei.com> - 2.1.1-3
|
||||
- backport community patches to fix mem leak in lib/sysfs_device.c and lib/sysfs_attr.c
|
||||
|
||||
* Tue Nov 1 2022 lihaoxiang <lihaoxiang9@huawei.com> - 2.1.1-2
|
||||
- fixed a memory leak in lib/sysfs_driver.c
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user