[PATCH net v5 4/4] netconsole: stop waiting for carrier once the device is unregistered

From
Gustavo Luiz Duarte <gustavold@gmail.com>
Date
2026-11-02 19:55:11
Also in
lkml
Reply to
Gustavo Luiz Duarte, 2026-11-02
netcons_netpoll_setup() releases RTNL and waits in netcons_wait_carrier()
for up to carrier_timeout seconds for the device to report carrier. If
the device is unregistered in the meantime, the loop keeps polling until
the timeout expires.

Stop waiting as soon as the device is no longer NETREG_REGISTERED.

Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261021-netcons-fixes-v4-0-3857120c6340@gmail.com
Signed-off-by: Gustavo Luiz Duarte <gustavold@gmail.com>
---
 drivers/net/netconsole.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 238acf300d23..895d33b179e7 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -383,6 +383,8 @@ static void netcons_wait_carrier(struct netpoll *np, struct net_device *ndev)
 
 	atmost = jiffies + netpoll_get_carrier_timeout() * HZ;
 	while (!netif_carrier_ok(ndev)) {
+		if (READ_ONCE(ndev->reg_state) != NETREG_REGISTERED)
+			break;
 		if (time_after(jiffies, atmost)) {
 			np_notice(np, "timeout waiting for carrier\n");
 			break;
-- 
2.56.0
Thread (10 messages) 10 messages, 3 authors, last reply 9d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help