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); } }