From: Yu Watanabe Date: Wed, 3 Jan 2024 19:10:31 +0000 (+0900) Subject: network/netdev: call done() per netdev kind before freeing netdev name or so X-Git-Tag: v256-rc1~1315 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f475584ebf3772b26c81d0f5efd690207feaa156;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c index 57127a861ab..894cec44cbb 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); }