The resource leak fixes

1. free the udev parent node automatically.
2. free new_model_name variable in the same scope.

Link c5df437cc1

Resolves: RHEL-130542
This commit is contained in:
Kate Hsuan 2025-11-28 15:44:02 +08:00
parent 098127a715
commit 9acfa1ff77
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,42 @@
From c5df437cc15580f617a7eb8f8e3e572c742624fa Mon Sep 17 00:00:00 2001
From: Kate Hsuan <hpa@redhat.com>
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

View File

@ -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