Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

K. Y. Srinivasan and committed by
Greg Kroah-Hartman
cf6a2eac d2554f50

+16
+16
drivers/hv/vmbus_drv.c
··· 62 62 struct hv_dev_port_info outbound; 63 63 }; 64 64 65 + static int vmbus_exists(void) 66 + { 67 + if (hv_acpi_dev == NULL) 68 + return -ENODEV; 69 + 70 + return 0; 71 + } 72 + 65 73 66 74 static void get_channel_info(struct hv_device *device, 67 75 struct hv_device_info *info) ··· 598 590 599 591 pr_info("registering driver %s\n", hv_driver->name); 600 592 593 + ret = vmbus_exists(); 594 + if (ret < 0) 595 + return ret; 596 + 601 597 hv_driver->driver.name = hv_driver->name; 602 598 hv_driver->driver.owner = owner; 603 599 hv_driver->driver.mod_name = mod_name; ··· 625 613 void vmbus_driver_unregister(struct hv_driver *hv_driver) 626 614 { 627 615 pr_info("unregistering driver %s\n", hv_driver->name); 616 + 617 + if (!vmbus_exists()) 618 + return; 628 619 629 620 driver_unregister(&hv_driver->driver); 630 621 ··· 791 776 792 777 cleanup: 793 778 acpi_bus_unregister_driver(&vmbus_acpi_driver); 779 + hv_acpi_dev = NULL; 794 780 return ret; 795 781 } 796 782