drop_netconsole_target() might eventually tear down a target that
netconsole_netdev_event() had moved to target_cleanup_list but that
netconsole_process_cleanups_core() had not processed yet.
Always cleanup devices that eventually have a device attached to the
target, independent of the state.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/net/netconsole.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index c1812a98365b7..a939daa07cf9d 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1481,15 +1481,15 @@ static void drop_netconsole_target(struct config_group *group,
mutex_lock(&target_cleanup_list_lock);
spin_lock_irqsave(&target_list_lock, flags);
- /* A STATE_DEACTIVATED target may have been moved to
- * target_cleanup_list by netconsole_netdev_event() but not yet
- * processed by netconsole_process_cleanups_core(). Unlinking it below
- * hides it from the cleanup worker, so this path has to clean it up
- * itself. Record that the target still owns a netpoll before the
- * state is downgraded.
+ /* A target moved to target_cleanup_list by netconsole_netdev_event()
+ * but not yet processed still owns a netpoll; unlinking it below hides
+ * it from the cleanup worker, so this path must tear it down itself.
+ * This covers NETDEV_UNREGISTER (STATE_DEACTIVATED) and
+ * NETDEV_RELEASE / NETDEV_JOIN (STATE_DISABLED); key off nt->np.dev,
+ * which stays set until the netpoll is cleaned up.
*/
needs_cleanup = nt->state == STATE_ENABLED ||
- nt->state == STATE_DEACTIVATED;
+ nt->state == STATE_DEACTIVATED || nt->np.dev;
/* Disable deactivated target to prevent races between resume attempt
* and target removal.
*/
--
2.53.0-Meta