aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hv
diff options
context:
space:
mode:
authorK. Y. Srinivasan <kys@microsoft.com>2011-12-01 12:59:34 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-12-09 19:23:49 -0500
commitcf6a2eacbcb2593b5b91d0817915c4f0464bb534 (patch)
tree720c96644b6d60ce2b8db2c52cb80591421e1b82 /drivers/hv
parentd2554f50df9be3c53a13f7541a5f4d054bd56cc3 (diff)
drivers: hv: Don't OOPS when you cannot init vmbus
The hv vmbus driver was causing an OOPS since it was trying to register drivers on top of the bus even if initialization of the bus has failed for some reason (such as the odd chance someone would run a hv enabled kernel in a non-hv environment). Signed-off-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hv')
-rw-r--r--drivers/hv/vmbus_drv.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 7d3bccb3b2a..40956d1c660 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -62,6 +62,14 @@ struct hv_device_info {
62 struct hv_dev_port_info outbound; 62 struct hv_dev_port_info outbound;
63}; 63};
64 64
65static int vmbus_exists(void)
66{
67 if (hv_acpi_dev == NULL)
68 return -ENODEV;
69
70 return 0;
71}
72
65 73
66static void get_channel_info(struct hv_device *device, 74static void get_channel_info(struct hv_device *device,
67 struct hv_device_info *info) 75 struct hv_device_info *info)
@@ -590,6 +598,10 @@ int __vmbus_driver_register(struct hv_driver *hv_driver, struct module *owner, c
590 598
591 pr_info("registering driver %s\n", hv_driver->name); 599 pr_info("registering driver %s\n", hv_driver->name);
592 600
601 ret = vmbus_exists();
602 if (ret < 0)
603 return ret;
604
593 hv_driver->driver.name = hv_driver->name; 605 hv_driver->driver.name = hv_driver->name;
594 hv_driver->driver.owner = owner; 606 hv_driver->driver.owner = owner;
595 hv_driver->driver.mod_name = mod_name; 607 hv_driver->driver.mod_name = mod_name;
@@ -614,6 +626,9 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver)
614{ 626{
615 pr_info("unregistering driver %s\n", hv_driver->name); 627 pr_info("unregistering driver %s\n", hv_driver->name);
616 628
629 if (!vmbus_exists())
630 return;
631
617 driver_unregister(&hv_driver->driver); 632 driver_unregister(&hv_driver->driver);
618 633
619} 634}
@@ -776,6 +791,7 @@ static int __init hv_acpi_init(void)
776 791
777cleanup: 792cleanup:
778 acpi_bus_unregister_driver(&vmbus_acpi_driver); 793 acpi_bus_unregister_driver(&vmbus_acpi_driver);
794 hv_acpi_dev = NULL;
779 return ret; 795 return ret;
780} 796}
781 797