Drivers: hv: vmbus: Fix potential crash on module unload
authorGuilherme G. Piccoli <gpiccoli@igalia.com>
Tue, 15 Mar 2022 20:35:35 +0000 (17:35 -0300)
committerWei Liu <wei.liu@kernel.org>
Tue, 29 Mar 2022 12:05:12 +0000 (12:05 +0000)
commit792f232d57ff28bbd5f9c4abe0466b23d5879dc8
tree8659d9f6788996a802b01f3be16a7ad71c0c8eaf
parent3a5469582c241abca22500f36a9cb8e9331969cf
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 74347a99e73a ("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: 74347a99e73a ("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>
drivers/hv/vmbus_drv.c