From: Juergen Gross Date: Tue, 21 Nov 2023 09:49:51 +0000 (+0100) Subject: Mini-OS: don't crash if no shutdown node is available X-Git-Tag: xen-4.19.0-rc4~45 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=961ed15f04f5d8fc96279836cf52bc36d0a5141e;p=mini-os.git Mini-OS: don't crash if no shutdown node is available It might be perfectly fine not to have a control/shutdown Xenstore node. If this is the case, don't crash, but just terminate the shutdown thread after issuing a message that shutdown isn't available. In fini_shutdown() clearing the watch can result in an error now, in case the early exit above was taken. Just ignore this error now. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- diff --git a/shutdown.c b/shutdown.c index bb2c6f1..ded6b64 100644 --- a/shutdown.c +++ b/shutdown.c @@ -75,7 +75,9 @@ static void shutdown_thread(void *p) xenbus_wait_for_watch(&events); if ((err = xenbus_read(XBT_NIL, path, &shutdown))) { free(err); - do_exit(); + free(xenbus_unwatch_path_token(XBT_NIL, path, token)); + printk("Shutdown Xenstore node not available.\n"); + return; } if (end_shutdown_thread) @@ -117,15 +119,9 @@ void init_shutdown(void) void fini_shutdown(void) { - char *err; - end_shutdown_thread = 1; xenbus_release_wait_for_watch(&events); - err = xenbus_unwatch_path_token(XBT_NIL, path, token); - if (err) { - free(err); - do_exit(); - } + free(xenbus_unwatch_path_token(XBT_NIL, path, token)); } #endif