From f475584ebf3772b26c81d0f5efd690207feaa156 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 4 Jan 2024 04:10:31 +0900 Subject: [PATCH] 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. --- src/network/netdev/netdev.c | 15 +++++++-------- 1 file 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); } -- 2.25.1