提交 56480287 编写于 作者: M Matthew Garrett 提交者: Linus Torvalds

ipmi: make sure drivers were registered before unregistering them

The ipmi code will never register a PCI or Open Firmware driver if a
hardcoded device is provided by the user by providing device addresses via
the module parameters.  This can cause us to attempt to unregister a
driver that was never registered, resulting in an oops.  Keep track of
registration in order to avoid this.

Fixes a post-2.6.34 regression.
Signed-off-by: NMatthew Garrett <mjg@redhat.com>
Acked-by: NCorey Minyard <cminyard@mvista.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 e05bd336
...@@ -302,6 +302,12 @@ struct smi_info { ...@@ -302,6 +302,12 @@ struct smi_info {
static int force_kipmid[SI_MAX_PARMS]; static int force_kipmid[SI_MAX_PARMS];
static int num_force_kipmid; static int num_force_kipmid;
#ifdef CONFIG_PCI
static int pci_registered;
#endif
#ifdef CONFIG_PPC_OF
static int of_registered;
#endif
static unsigned int kipmid_max_busy_us[SI_MAX_PARMS]; static unsigned int kipmid_max_busy_us[SI_MAX_PARMS];
static int num_max_busy_us; static int num_max_busy_us;
...@@ -3314,6 +3320,8 @@ static __devinit int init_ipmi_si(void) ...@@ -3314,6 +3320,8 @@ static __devinit int init_ipmi_si(void)
rv = pci_register_driver(&ipmi_pci_driver); rv = pci_register_driver(&ipmi_pci_driver);
if (rv) if (rv)
printk(KERN_ERR PFX "Unable to register PCI driver: %d\n", rv); printk(KERN_ERR PFX "Unable to register PCI driver: %d\n", rv);
else
pci_registered = 1;
#endif #endif
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
...@@ -3330,6 +3338,7 @@ static __devinit int init_ipmi_si(void) ...@@ -3330,6 +3338,7 @@ static __devinit int init_ipmi_si(void)
#ifdef CONFIG_PPC_OF #ifdef CONFIG_PPC_OF
of_register_platform_driver(&ipmi_of_platform_driver); of_register_platform_driver(&ipmi_of_platform_driver);
of_registered = 1;
#endif #endif
/* We prefer devices with interrupts, but in the case of a machine /* We prefer devices with interrupts, but in the case of a machine
...@@ -3383,10 +3392,12 @@ static __devinit int init_ipmi_si(void) ...@@ -3383,10 +3392,12 @@ static __devinit int init_ipmi_si(void)
if (unload_when_empty && list_empty(&smi_infos)) { if (unload_when_empty && list_empty(&smi_infos)) {
mutex_unlock(&smi_infos_lock); mutex_unlock(&smi_infos_lock);
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
if (pci_registered)
pci_unregister_driver(&ipmi_pci_driver); pci_unregister_driver(&ipmi_pci_driver);
#endif #endif
#ifdef CONFIG_PPC_OF #ifdef CONFIG_PPC_OF
if (of_registered)
of_unregister_platform_driver(&ipmi_of_platform_driver); of_unregister_platform_driver(&ipmi_of_platform_driver);
#endif #endif
driver_unregister(&ipmi_driver.driver); driver_unregister(&ipmi_driver.driver);
...@@ -3478,6 +3489,7 @@ static __exit void cleanup_ipmi_si(void) ...@@ -3478,6 +3489,7 @@ static __exit void cleanup_ipmi_si(void)
return; return;
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
if (pci_registered)
pci_unregister_driver(&ipmi_pci_driver); pci_unregister_driver(&ipmi_pci_driver);
#endif #endif
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
...@@ -3485,6 +3497,7 @@ static __exit void cleanup_ipmi_si(void) ...@@ -3485,6 +3497,7 @@ static __exit void cleanup_ipmi_si(void)
#endif #endif
#ifdef CONFIG_PPC_OF #ifdef CONFIG_PPC_OF
if (of_registered)
of_unregister_platform_driver(&ipmi_of_platform_driver); of_unregister_platform_driver(&ipmi_of_platform_driver);
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册