Skip to content

Commit 792f232

Browse files
guilhermepiccoliliuw
authored andcommitted
Drivers: hv: vmbus: Fix potential crash on module unload
The vmbus driver relies on the panic notifier infrastructure to perform some operations when a panic event is detected. Since vmbus can be built as module, it is required that the driver handles both registering and unregistering such panic notifier callback. After commit 74347a9 ("x86/Hyper-V: Unload vmbus channel in hv panic callback") though, the panic notifier registration is done unconditionally in the module initialization routine whereas the unregistering procedure is conditionally guarded and executes only if HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE capability is set. This patch fixes that by unconditionally unregistering the panic notifier in the module's exit routine as well. Fixes: 74347a9 ("x86/Hyper-V: Unload vmbus channel in hv panic callback") Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Link: https://lore.kernel.org/r/20220315203535.682306-1-gpiccoli@igalia.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent 3a54695 commit 792f232

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

drivers/hv/vmbus_drv.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2787,10 +2787,15 @@ static void __exit vmbus_exit(void)
27872787
if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {
27882788
kmsg_dump_unregister(&hv_kmsg_dumper);
27892789
unregister_die_notifier(&hyperv_die_block);
2790-
atomic_notifier_chain_unregister(&panic_notifier_list,
2791-
&hyperv_panic_block);
27922790
}
27932791

2792+
/*
2793+
* The panic notifier is always registered, hence we should
2794+
* also unconditionally unregister it here as well.
2795+
*/
2796+
atomic_notifier_chain_unregister(&panic_notifier_list,
2797+
&hyperv_panic_block);
2798+
27942799
free_page((unsigned long)hv_panic_page);
27952800
unregister_sysctl_table(hv_ctl_table_hdr);
27962801
hv_ctl_table_hdr = NULL;

0 commit comments

Comments
 (0)