fixed a memory leak in lib/sysfs_driver.c

(cherry picked from commit 1328ca91f409dad0ef94a85537b349654b16379a)
This commit is contained in:
lihaoxiang 2022-11-01 01:59:15 +00:00 committed by openeuler-sync-bot
parent c46c1560db
commit 03ff80c5eb
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,28 @@
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
@@ -255,6 +255,7 @@ struct dlist *sysfs_get_driver_devices(struct sysfs_driver *drv)
if (!drv->devices) {
dbg_printf("Error creating device list\n");
sysfs_close_list(linklist);
+ sysfs_close_device(dev);
return NULL;
}
}
--
2.37.0.windows.1

View File

@ -1,12 +1,13 @@
Name: sysfsutils
Version: 2.1.1
Release: 1
Release: 2
Summary: A set of utilities for interfacing with sysfs
License: GPLv2 and LGPLv2+
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
BuildRequires: gcc chrpath autoconf automake make libtool
Provides: libsysfs libsysfs%{?_isa}
@ -80,6 +81,9 @@ chrpath -d $(find $RPM_BUILD_ROOT -name systool)
%changelog
* Tue Nov 1 2022 lihaoxiang <lihaoxiang9@huawei.com> - 2.1.1-2
- fixed a memory leak in lib/sysfs_driver.c
* Thu Nov 25 2021 yanglongkang <yanglongkang@huawei.com> - 2.1.1-1
- update to 2.1.1