Commit 7d815f4a authored by Haiyang Zhang's avatar Haiyang Zhang Committed by Wei Liu

PCI: hv: Add check for hyperv_initialized in init_hv_pci_drv()

Add check for hv_is_hyperv_initialized() at the top of
init_hv_pci_drv(), so if the pci-hyperv driver is force-loaded on non
Hyper-V platforms, the init_hv_pci_drv() will exit immediately, without
any side effects, like assignments to hvpci_block_ops, etc.
Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Reported-and-tested-by: default avatarMohammad Alqayeem <mohammad.alqyeem@nutanix.com>
Reviewed-by: default avatarWei Liu <wei.liu@kernel.org>
Link: https://lore.kernel.org/r/1621984653-1210-1-git-send-email-haiyangz@microsoft.comSigned-off-by: default avatarWei Liu <wei.liu@kernel.org>
parent a4d7e8ae
...@@ -3476,6 +3476,9 @@ static void __exit exit_hv_pci_drv(void) ...@@ -3476,6 +3476,9 @@ static void __exit exit_hv_pci_drv(void)
static int __init init_hv_pci_drv(void) static int __init init_hv_pci_drv(void)
{ {
if (!hv_is_hyperv_initialized())
return -ENODEV;
/* Set the invalid domain number's bit, so it will not be used */ /* Set the invalid domain number's bit, so it will not be used */
set_bit(HVPCI_DOM_INVALID, hvpci_dom_map); set_bit(HVPCI_DOM_INVALID, hvpci_dom_map);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment