From 1e0d7c870d0ef64f6a37335e8928cc0e710364d4 Mon Sep 17 00:00:00 2001
From: Super User <root@localhost.localdomain>
Date: Wed, 27 Nov 2024 16:44:38 +0800
Subject: [PATCH] backport to fix memory leak

---
 ...me_device-free-path-after-it-is-used.patch | 33 +++++++++++++++++++
 initscripts.spec                              |  9 ++++-
 2 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 backport-rename_device-free-path-after-it-is-used.patch

diff --git a/backport-rename_device-free-path-after-it-is-used.patch b/backport-rename_device-free-path-after-it-is-used.patch
new file mode 100644
index 0000000..c8f1c36
--- /dev/null
+++ b/backport-rename_device-free-path-after-it-is-used.patch
@@ -0,0 +1,33 @@
+From 2b185d6bb1eda7e5bdd885afc88bf404d2c1f861 Mon Sep 17 00:00:00 2001
+From: Lukas Nykryn <lnykryn@redhat.com>
+Date: Fri, 1 Mar 2024 14:36:45 +0100
+Subject: [PATCH] rename_device: free path after it is used
+
+---
+ src/rename_device.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/rename_device.c b/src/rename_device.c
+index 0d29f64d..e6b09f45 100644
+--- a/src/rename_device.c
++++ b/src/rename_device.c
+@@ -180,7 +180,7 @@ struct netdev *get_configs() {
+ 		return ret;
+ 	}
+ 	for (x = 0; x < ncfgs; x++ ) {
+-		char *path;
++		char *path = NULL;
+ 		char *devname, *hwaddr;
+ 		int vlan;
+ 		gchar *contents, **lines;
+@@ -193,6 +193,7 @@ struct netdev *get_configs() {
+ 			     cfgs[x]->d_name) == -1)
+ 			continue;
+ 		g_file_get_contents(path, &contents, NULL, NULL);
++		free(path);
+ 		if (!contents)
+ 			continue;
+ 		lines = g_strsplit(contents,"\n", 0);
+-- 
+2.43.0
+
diff --git a/initscripts.spec b/initscripts.spec
index a299c74..6b07f0f 100644
--- a/initscripts.spec
+++ b/initscripts.spec
@@ -20,7 +20,7 @@ Requires:         gawk                       \
 Name:             initscripts
 Summary:          Basic support for legacy System V init scripts
 Version:          10.19
-Release:          1
+Release:          2
 
 License:          GPL-2.0-only
 
@@ -91,6 +91,7 @@ Patch9004: new-network-fork-to-start-dhcp.patch
 Patch9005: exec-udevadm-settle-when-network-start.patch
 Patch9006: remove-rename_device_lock-when-process-does-not-exis.patch
 Patch9007: support-specify-cc.patch
+Patch9008: backport-rename_device-free-path-after-it-is-used.patch
 
 %description
 This package provides basic support for legacy System V init scripts, and some
@@ -386,6 +387,12 @@ fi
 # =============================================================================
 
 %changelog
+* Wed Nov 27 2024 liyunqing <liyunqing@kylinos.cn> - 10.19-2
+- Type: bugfix
+- ID: NA
+- SUG: NA
+- DESC: backport to fix memory leak 
+
 * Thu Feb 1 2024 liubo <liubo335@huawei.com> - 10.19-1
 - Type: requirement
 - ID: NA
-- 
Gitee