1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00

network/netdev: call done() per netdev kind before freeing netdev name or so

Otherwise, log_netdev_xyz() does not provide netdev name if it is called
in done(). It is hard to debug.

This should not change any effective behavior, at least with the current
implementation of done() per netdev kind.
This commit is contained in:
Yu Watanabe 2024-01-04 04:10:31 +09:00 committed by Mike Yuan
parent efc438d928
commit f475584ebf

View File

@ -198,14 +198,6 @@ static void netdev_detach_from_manager(NetDev *netdev) {
static NetDev *netdev_free(NetDev *netdev) {
assert(netdev);
netdev_detach_from_manager(netdev);
free(netdev->filename);
free(netdev->description);
free(netdev->ifname);
condition_free_list(netdev->conditions);
/* Invoke the per-kind done() destructor, but only if the state field is initialized. We conditionalize that
* because we parse .netdev files twice: once to determine the kind (with a short, minimal NetDev structure
* allocation, with no room for per-kind fields), and once to read the kind's properties (with a full,
@ -218,6 +210,13 @@ static NetDev *netdev_free(NetDev *netdev) {
NETDEV_VTABLE(netdev)->done)
NETDEV_VTABLE(netdev)->done(netdev);
netdev_detach_from_manager(netdev);
condition_free_list(netdev->conditions);
free(netdev->filename);
free(netdev->description);
free(netdev->ifname);
return mfree(netdev);
}