fix use-after-free on device free codepath due to recursion issues, and fix dev-...
[project/netifd.git] / device.h
index a3728f3..c0b112d 100644 (file)
--- a/device.h
+++ b/device.h
@@ -111,6 +111,7 @@ struct device {
 };
 
 struct device_hotplug_ops {
+       int (*prepare)(struct device *dev);
        int (*add)(struct device *main, struct device *member);
        int (*del)(struct device *main, struct device *member);
 };
@@ -147,12 +148,7 @@ void device_release(struct device_user *dep);
 int device_check_state(struct device *dev);
 void device_dump_status(struct blob_buf *b, struct device *dev);
 
-static inline void
-device_free(struct device *dev)
-{
-       dev->type->free(dev);
-}
-
+void device_free(struct device *dev);
 void device_free_unused(struct device *dev);
 
 struct device *get_vlan_device_chain(const char *ifname, bool create);