summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>2009-08-19 05:58:46 +0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-09-10 00:29:45 +0400
commitfc87e919c0ce8e213edf2ffca17f384f059873d3 (patch)
tree0bd3d67b0320c486e9ec1c846569c3a72baf6bc7
parent8a339e7321f10dc2f28928ffadb69b6c7c2d5c3b (diff)
downloadlinux-fc87e919c0ce8e213edf2ffca17f384f059873d3.tar.xz
PCI ASPM: fix possible null pointer dereference
Fix possible NULL dereference in pcie_aspm_exit_link_state(). This patch also cleanup some code. Acked-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
-rw-r--r--drivers/pci/pcie/aspm.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 638881b00f6b..0800c5146826 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -665,16 +665,16 @@ out:
void pcie_aspm_exit_link_state(struct pci_dev *pdev)
{
struct pci_dev *parent = pdev->bus->self;
- struct pcie_link_state *link_state = parent->link_state;
+ struct pcie_link_state *link;
- if (aspm_disabled || !pdev->is_pcie || !parent || !link_state)
+ if (aspm_disabled || !pdev->is_pcie || !parent || !parent->link_state)
return;
if (parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT &&
- parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)
+ parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)
return;
+
down_read(&pci_bus_sem);
mutex_lock(&aspm_lock);
-
/*
* All PCIe functions are in one slot, remove one function will remove
* the whole slot, so just wait until we are the last function left.
@@ -682,13 +682,14 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
if (!list_is_last(&pdev->bus_list, &parent->subordinate->devices))
goto out;
+ link = parent->link_state;
+
/* All functions are removed, so just disable ASPM for the link */
__pcie_aspm_config_one_dev(parent, 0);
- list_del(&link_state->sibling);
- list_del(&link_state->link);
+ list_del(&link->sibling);
+ list_del(&link->link);
/* Clock PM is for endpoint device */
-
- free_link_state(link_state);
+ free_link_state(link);
out:
mutex_unlock(&aspm_lock);
up_read(&pci_bus_sem);