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.
This commit is contained in:
Kate Hsuan 2025-11-27 17:17:10 +08:00
parent d79841fe40
commit c5df437cc1

View file

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