From: Andrew Morton <akpm@linux-foundation.org>
To: Matthew Garrett <mjg@redhat.com>
Cc: minyard@acm.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipmi: Make sure drivers were registered before unregistering them
Date: Mon, 14 Jun 2010 13:36:08 -0700 [thread overview]
Message-ID: <20100614133608.b343cb84.akpm@linux-foundation.org> (raw)
In-Reply-To: <1276192406-3612-1-git-send-email-mjg@redhat.com>
On Thu, 10 Jun 2010 13:53:26 -0400
Matthew Garrett <mjg@redhat.com> wrote:
> The ipmi code will never register a PCI or Open Firmware driver if
> a hardcoded device is provided by the user.
How does a user "provide a hardcoded device"?
> 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.
>
I tried to work out from the above whether we want to backport this fix
into -stable and failed. And I reckon that if I can't work this out
from a changelog, the changelog is inadequate.
> --- a/drivers/char/ipmi/ipmi_si_intf.c
> +++ b/drivers/char/ipmi/ipmi_si_intf.c
> @@ -302,6 +302,12 @@ struct smi_info {
>
> static int force_kipmid[SI_MAX_PARMS];
> 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 int num_max_busy_us;
> @@ -3314,6 +3320,8 @@ static __devinit int init_ipmi_si(void)
> rv = pci_register_driver(&ipmi_pci_driver);
> if (rv)
> printk(KERN_ERR PFX "Unable to register PCI driver: %d\n", rv);
> + else
> + pci_registered = 1;
> #endif
>
> #ifdef CONFIG_ACPI
> @@ -3330,6 +3338,7 @@ static __devinit int init_ipmi_si(void)
>
> #ifdef CONFIG_PPC_OF
> of_register_platform_driver(&ipmi_of_platform_driver);
> + of_registered = 1;
I assume the code will still oops if of_register_platform_driver() failed.
> #endif
>
> /* We prefer devices with interrupts, but in the case of a machine
> @@ -3383,11 +3392,13 @@ static __devinit int init_ipmi_si(void)
> if (unload_when_empty && list_empty(&smi_infos)) {
> mutex_unlock(&smi_infos_lock);
> #ifdef CONFIG_PCI
> - pci_unregister_driver(&ipmi_pci_driver);
> + if (pci_registered)
> + pci_unregister_driver(&ipmi_pci_driver);
> #endif
>
> #ifdef CONFIG_PPC_OF
> - of_unregister_platform_driver(&ipmi_of_platform_driver);
> + if (of_registered)
> + of_unregister_platform_driver(&ipmi_of_platform_driver);
> #endif
> driver_unregister(&ipmi_driver.driver);
> printk(KERN_WARNING PFX
> @@ -3478,14 +3489,16 @@ static __exit void cleanup_ipmi_si(void)
> return;
>
> #ifdef CONFIG_PCI
> - pci_unregister_driver(&ipmi_pci_driver);
> + if (pci_registered)
> + pci_unregister_driver(&ipmi_pci_driver);
> #endif
> #ifdef CONFIG_ACPI
> pnp_unregister_driver(&ipmi_pnp_driver);
> #endif
>
> #ifdef CONFIG_PPC_OF
> - of_unregister_platform_driver(&ipmi_of_platform_driver);
> + if (of_registered)
> + of_unregister_platform_driver(&ipmi_of_platform_driver);
> #endif
>
> mutex_lock(&smi_infos_lock);
next prev parent reply other threads:[~2010-06-14 20:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-10 17:53 [PATCH] ipmi: Make sure drivers were registered before unregistering them Matthew Garrett
2010-06-10 18:11 ` Corey Minyard
2010-06-14 20:36 ` Andrew Morton [this message]
2010-06-14 20:47 ` Matthew Garrett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100614133608.b343cb84.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minyard@acm.org \
--cc=mjg@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.