From 9acfa1ff7763e9e851b62fb3ab5deb0ed1178df7 Mon Sep 17 00:00:00 2001 From: Kate Hsuan Date: Fri, 28 Nov 2025 15:44:02 +0800 Subject: [PATCH] The resource leak fixes 1. free the udev parent node automatically. 2. free new_model_name variable in the same scope. Link https://gitlab.freedesktop.org/upower/upower/-/commit/c5df437cc15580f617a7eb8f8e3e572c742624fa Resolves: RHEL-130542 --- ...-device-supply-fix-the-resource-leak.patch | 42 +++++++++++++++++++ upower.spec | 1 + 2 files changed, 43 insertions(+) create mode 100644 0001-linux-up-device-supply-fix-the-resource-leak.patch diff --git a/0001-linux-up-device-supply-fix-the-resource-leak.patch b/0001-linux-up-device-supply-fix-the-resource-leak.patch new file mode 100644 index 0000000..eac96f2 --- /dev/null +++ b/0001-linux-up-device-supply-fix-the-resource-leak.patch @@ -0,0 +1,42 @@ +From c5df437cc15580f617a7eb8f8e3e572c742624fa Mon Sep 17 00:00:00 2001 +From: Kate Hsuan +Date: Thu, 27 Nov 2025 17:17:10 +0800 +Subject: [PATCH] linux: up-device-supply: fix the resource leak + +1. free the udev parent node automatically. +2. free new_model_name variable in the same scope. +--- + src/linux/up-device-supply.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c +index 889367f..ae4e696 100644 +--- a/src/linux/up-device-supply.c ++++ b/src/linux/up-device-supply.c +@@ -331,7 +331,9 @@ static void + up_device_supply_sibling_discovered_guess_type (UpDevice *device, + GObject *sibling) + { +- GUdevDevice *input, *native_device, *parent_device, *parent_sibling; ++ GUdevDevice *input, *native_device; ++ g_autoptr (GUdevDevice) parent_device = NULL; ++ g_autoptr (GUdevDevice) parent_sibling = NULL; + UpDeviceKind cur_type, new_type; + gboolean is_same_parent = FALSE; + char *new_model_name; +@@ -492,9 +494,10 @@ up_device_supply_sibling_discovered_guess_type (UpDevice *device, + "type", new_type, + "model", new_model_name, + NULL); +- g_free (new_model_name); +- } else ++ } else { + g_object_set (device, "type", new_type, NULL); ++ } ++ g_free (new_model_name); + } + } + +-- +2.51.1 + diff --git a/upower.spec b/upower.spec index a0b0ecd..e7b81c2 100644 --- a/upower.spec +++ b/upower.spec @@ -27,6 +27,7 @@ Requires: %{name}-libs%{?_isa} = %{version}-%{release} Requires: udev # Patches +Patch0001: 0001-linux-up-device-supply-fix-the-resource-leak.patch %description UPower (formerly DeviceKit-power) provides a daemon, API and command