git: 902b401a51c8 - main - asmc: do not drop shutdown notification when the system node fails

From: Abdelkader Boudih <seuros_at_FreeBSD.org>
Date: Sun, 15 Nov 2026 21:21:50 UTC
The branch main has been updated by seuros:

URL: https://cgit.FreeBSD.org/src/commit/?id=902b401a51c8165a3af23466acabe912c9a48b34

commit 902b401a51c8165a3af23466acabe912c9a48b34
Author:     Abdelkader Boudih <seuros@FreeBSD.org>
AuthorDate: 2026-11-15 21:12:44 +0000
Commit:     Abdelkader Boudih <seuros@FreeBSD.org>
CommitDate: 2026-11-15 21:12:44 +0000

    asmc: do not drop shutdown notification when the system node fails
    
    asmc_attach() registered the MBSS shutdown-cause handler
    (EVENTHANDLER_REGISTER(shutdown_pre_sync, asmc_shutdown, ...))
    after attempting to add the dev.asmc.N.system sysctl subtree. If that
    subtree registration failed, the error path took goto nosms, jumping clean
    over the shutdown-handler registration. On T2 Macs this silently drops
    the only thing standing between a clean shutdown and bridgeOS's
    watchdog power-cycling the machine.
    
    MFC after:      3 days
    
    Reviewed by:    ngie
    
    Differential Revision:  https://reviews.freebsd.org/D61482
---
 sys/dev/asmc/asmc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c
index b4310d77ab5e..f7635b4d7550 100644
--- a/sys/dev/asmc/asmc.c
+++ b/sys/dev/asmc/asmc.c
@@ -275,14 +275,13 @@ asmc_attach(device_t dev)
 		    "Battery charge limit (0-100)");
 	}
 
-	/* System state / board identity subtree. */
-	if (asmc_sysctl_add_system(dev, sysctlctx) != 0)
-		goto nosms;
-
 	if (asmc_key_getinfo(dev, ASMC_KEY_MBSS, NULL, NULL) == 0)
 		sc->sc_shutdown_tag = EVENTHANDLER_REGISTER(shutdown_pre_sync,
 		    asmc_shutdown, dev, SHUTDOWN_PRI_FIRST);
 
+	/* System state / board identity subtree. */
+	(void)asmc_sysctl_add_system(dev, sysctlctx);
+
 	if (!sc->sc_has_sms)
 		goto nosms;