diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-01-03 20:10:31 +0100 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2024-01-04 13:34:14 +0100 |
commit | f475584ebf3772b26c81d0f5efd690207feaa156 (patch) | |
tree | 602294efd192765ec620e423f155fa48256a424f /src/network/netdev | |
parent | tpm2-generator: sort includes (diff) | |
download | systemd-f475584ebf3772b26c81d0f5efd690207feaa156.tar.xz systemd-f475584ebf3772b26c81d0f5efd690207feaa156.zip |
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.
Diffstat (limited to 'src/network/netdev')
-rw-r--r-- | src/network/netdev/netdev.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c index 57127a861a..894cec44cb 100644 --- a/src/network/netdev/netdev.c +++ b/src/network/netdev/netdev.c @@ -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); } |