* [PATCH 1/1] PCI: hotplug/cpqphp, fix NULL dereference
@ 2010-06-09 20:31 Jiri Slaby
2010-06-09 22:34 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Slaby @ 2010-06-09 20:31 UTC (permalink / raw)
To: jbarnes; +Cc: linux-pci, linux-kernel, jirislaby, Greg KH
There are devices out there which are PCI Hot-plug controllers with
compaq PCI IDs, but are not bridges, hence have pdev->subordinate
NULL. But cpqphp expects the pointer to be non-NULL.
Add a check to the probe function to avoid oopses like:
BUG: unable to handle kernel NULL pointer dereference at 00000050
IP: [<f82e3c41>] cpqhpc_probe+0x951/0x1120 [cpqphp]
*pdpt = 0000000033779001 *pde = 0000000000000000
...
The device here was:
00:0b.0 PCI Hot-plug controller [0804]: Compaq Computer Corporation PCI Hotplug Controller [0e11:a0f7] (rev 11)
Subsystem: Compaq Computer Corporation Device [0e11:a2f8]
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Greg KH <greg@kroah.com>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
---
drivers/pci/hotplug/cpqphp_core.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index b3e5580..4952c3b 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -828,7 +828,14 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
pci_name(pdev), err);
return err;
}
+
bus = pdev->subordinate;
+ if (!bus) {
+ dev_notice(&pdev->dev, "the device is not a bridge, "
+ "skipping\n");
+ rc = -ENODEV;
+ goto err_disable_device;
+ }
/* Need to read VID early b/c it's used to differentiate CPQ and INTC
* discovery
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 1/1] PCI: hotplug/cpqphp, fix NULL dereference
2010-06-09 20:31 [PATCH 1/1] PCI: hotplug/cpqphp, fix NULL dereference Jiri Slaby
@ 2010-06-09 22:34 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2010-06-09 22:34 UTC (permalink / raw)
To: Jiri Slaby; +Cc: jbarnes, linux-pci, linux-kernel, jirislaby
On Wed, Jun 09, 2010 at 10:31:13PM +0200, Jiri Slaby wrote:
> There are devices out there which are PCI Hot-plug controllers with
> compaq PCI IDs, but are not bridges, hence have pdev->subordinate
> NULL. But cpqphp expects the pointer to be non-NULL.
>
> Add a check to the probe function to avoid oopses like:
> BUG: unable to handle kernel NULL pointer dereference at 00000050
> IP: [<f82e3c41>] cpqhpc_probe+0x951/0x1120 [cpqphp]
> *pdpt = 0000000033779001 *pde = 0000000000000000
> ...
>
> The device here was:
> 00:0b.0 PCI Hot-plug controller [0804]: Compaq Computer Corporation PCI Hotplug Controller [0e11:a0f7] (rev 11)
> Subsystem: Compaq Computer Corporation Device [0e11:a2f8]
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Greg KH <greg@kroah.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-09 22:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-09 20:31 [PATCH 1/1] PCI: hotplug/cpqphp, fix NULL dereference Jiri Slaby
2010-06-09 22:34 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox