]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/netdev: call done() per netdev kind before freeing netdev name or so
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 3 Jan 2024 19:10:31 +0000 (04:10 +0900)
committerMike Yuan <me@yhndnzj.com>
Thu, 4 Jan 2024 12:34:14 +0000 (20:34 +0800)
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

index 57127a861abad48aa330f81655e8069105c3d4bd..894cec44cbb574923d9d4a3cf64041ec4604b280 100644 (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);
 }