mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 10:31:33 -04:00
xenbus: Unregister reboot notifier on init failure
xs_init() registers xs_reboot_nb before initializing XenStore
communications and starting xenwatch. If either operation fails, the
notifier remains registered and a later initialization attempt can hit a
duplicate registration.
Check the notifier registration result and unregister it on every
subsequent failure path.
Fixes: fd8aa9095a ("xen: optimize xenbus driver for multiple concurrent xenstore accesses")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20260807032326.940377-1-dbgh9129@gmail.com>
This commit is contained in:
@@ -915,19 +915,27 @@ int xs_init(void)
|
||||
int err;
|
||||
struct task_struct *task;
|
||||
|
||||
register_reboot_notifier(&xs_reboot_nb);
|
||||
err = register_reboot_notifier(&xs_reboot_nb);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Initialize the shared memory rings to talk to xenstored */
|
||||
err = xb_init_comms();
|
||||
if (err)
|
||||
return err;
|
||||
goto err_unregister_reboot_notifier;
|
||||
|
||||
task = kthread_run(xenwatch_thread, NULL, "xenwatch");
|
||||
if (IS_ERR(task))
|
||||
return PTR_ERR(task);
|
||||
if (IS_ERR(task)) {
|
||||
err = PTR_ERR(task);
|
||||
goto err_unregister_reboot_notifier;
|
||||
}
|
||||
|
||||
/* shutdown watches for kexec boot */
|
||||
xs_reset_watches();
|
||||
|
||||
return 0;
|
||||
|
||||
err_unregister_reboot_notifier:
|
||||
unregister_reboot_notifier(&xs_reboot_nb);
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user