diff options
author | Mitchell Horne <mhorne@FreeBSD.org> | 2023-01-23 18:47:11 +0000 |
---|---|---|
committer | Mitchell Horne <mhorne@FreeBSD.org> | 2023-02-06 19:34:36 +0000 |
commit | 2f12145a37befc2bae3db859699d394611e96e2d (patch) | |
tree | 44c3352d62ca8f2f7ef01b371b551b86f77e8787 | |
parent | 11ade1dffc8dbdcf2541b2f9b2da61a998ccafc7 (diff) | |
download | src-2f12145a37befc2bae3db859699d394611e96e2d.tar.gz src-2f12145a37befc2bae3db859699d394611e96e2d.zip |
kern_reboot: unconditionally call shutdown_reset()
Currently shutdown_reset() is registered as the final entry of the
shutdown_final event handler. However, if a panic occurs early in boot
before the event is registered (SI_SUB_INTRINSIC), we may end up
spinning in the subsequent infinite for loop and failing to reset
altogether. Instead we can simply call this function unconditionally.
Reviewed by: markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D37981
(cherry picked from commit 627ca221c311b5d9c4132e03664a96f390ff5c0d)
-rw-r--r-- | sys/kern/kern_shutdown.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index aaa5c5a0243f..ee6faa222206 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -265,8 +265,6 @@ shutdown_conf(void *unused) SHUTDOWN_PRI_LAST + 100); EVENTHANDLER_REGISTER(shutdown_final, shutdown_panic, NULL, SHUTDOWN_PRI_LAST + 100); - EVENTHANDLER_REGISTER(shutdown_final, shutdown_reset, NULL, - SHUTDOWN_PRI_LAST + 200); } SYSINIT(shutdown_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, shutdown_conf, NULL); @@ -499,6 +497,12 @@ kern_reboot(int howto) /* Now that we're going to really halt the system... */ EVENTHANDLER_INVOKE(shutdown_final, howto); + /* + * Call this directly so that reset is attempted even if shutdown + * handlers are not yet registered. + */ + shutdown_reset(NULL, howto); + for(;;) ; /* safety against shutdown_reset not working */ /* NOTREACHED */ } |