diff options
author | Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> | 2009-08-18 21:58:46 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-09-09 16:29:45 -0400 |
commit | fc87e919c0ce8e213edf2ffca17f384f059873d3 (patch) | |
tree | 0bd3d67b0320c486e9ec1c846569c3a72baf6bc7 /drivers/pci/pcie | |
parent | 8a339e7321f10dc2f28928ffadb69b6c7c2d5c3b (diff) |
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>
Diffstat (limited to 'drivers/pci/pcie')
-rw-r--r-- | drivers/pci/pcie/aspm.c | 17 |
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: | |||
665 | void pcie_aspm_exit_link_state(struct pci_dev *pdev) | 665 | void pcie_aspm_exit_link_state(struct pci_dev *pdev) |
666 | { | 666 | { |
667 | struct pci_dev *parent = pdev->bus->self; | 667 | struct pci_dev *parent = pdev->bus->self; |
668 | struct pcie_link_state *link_state = parent->link_state; | 668 | struct pcie_link_state *link; |
669 | 669 | ||
670 | if (aspm_disabled || !pdev->is_pcie || !parent || !link_state) | 670 | if (aspm_disabled || !pdev->is_pcie || !parent || !parent->link_state) |
671 | return; | 671 | return; |
672 | if (parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT && | 672 | if (parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT && |
673 | parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) | 673 | parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) |
674 | return; | 674 | return; |
675 | |||
675 | down_read(&pci_bus_sem); | 676 | down_read(&pci_bus_sem); |
676 | mutex_lock(&aspm_lock); | 677 | mutex_lock(&aspm_lock); |
677 | |||
678 | /* | 678 | /* |
679 | * All PCIe functions are in one slot, remove one function will remove | 679 | * All PCIe functions are in one slot, remove one function will remove |
680 | * the whole slot, so just wait until we are the last function left. | 680 | * 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) | |||
682 | if (!list_is_last(&pdev->bus_list, &parent->subordinate->devices)) | 682 | if (!list_is_last(&pdev->bus_list, &parent->subordinate->devices)) |
683 | goto out; | 683 | goto out; |
684 | 684 | ||
685 | link = parent->link_state; | ||
686 | |||
685 | /* All functions are removed, so just disable ASPM for the link */ | 687 | /* All functions are removed, so just disable ASPM for the link */ |
686 | __pcie_aspm_config_one_dev(parent, 0); | 688 | __pcie_aspm_config_one_dev(parent, 0); |
687 | list_del(&link_state->sibling); | 689 | list_del(&link->sibling); |
688 | list_del(&link_state->link); | 690 | list_del(&link->link); |
689 | /* Clock PM is for endpoint device */ | 691 | /* Clock PM is for endpoint device */ |
690 | 692 | free_link_state(link); | |
691 | free_link_state(link_state); | ||
692 | out: | 693 | out: |
693 | mutex_unlock(&aspm_lock); | 694 | mutex_unlock(&aspm_lock); |
694 | up_read(&pci_bus_sem); | 695 | up_read(&pci_bus_sem); |