@@ -14,6 +14,7 @@
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/proc_fs.h>
+#include <linux/fwnode.h>
#include "of_private.h"
@@ -518,6 +519,13 @@ EXPORT_SYMBOL(of_changeset_create_node);
static void __of_changeset_entry_destroy(struct of_changeset_entry *ce)
{
+ /*
+ * device links drop their device references (and hence their of_node
+ * references) asynchronously on a dedicated workqueue. Hence we need
+ * to flush it to make sure everything is done before doing the below
+ * checks.
+ */
+ fwnode_links_flush_queue();
if (ce->action == OF_RECONFIG_ATTACH_NODE &&
of_node_check_flag(ce->np, OF_OVERLAY)) {
if (kref_read(&ce->np->kobj.kref) > 1) {