提交 8b662fe7 编写于 作者: G Gavin Shan 提交者: David S. Miller

net/cxgb4: Fix referencing freed adapter

The adapter is freed before we check its flags. It was caused
by commit 144be3d9 ("net/cxgb4: Avoid disabling PCI device for
towice"). The problem was reported by Intel's "0-day" tool.

The patch fixes it to avoid reverting commit 144be3d9.
Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NGavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 33d99113
...@@ -6163,13 +6163,13 @@ static void remove_one(struct pci_dev *pdev) ...@@ -6163,13 +6163,13 @@ static void remove_one(struct pci_dev *pdev)
iounmap(adapter->regs); iounmap(adapter->regs);
if (!is_t4(adapter->params.chip)) if (!is_t4(adapter->params.chip))
iounmap(adapter->bar2); iounmap(adapter->bar2);
kfree(adapter);
pci_disable_pcie_error_reporting(pdev); pci_disable_pcie_error_reporting(pdev);
if ((adapter->flags & DEV_ENABLED)) { if ((adapter->flags & DEV_ENABLED)) {
pci_disable_device(pdev); pci_disable_device(pdev);
adapter->flags &= ~DEV_ENABLED; adapter->flags &= ~DEV_ENABLED;
} }
pci_release_regions(pdev); pci_release_regions(pdev);
kfree(adapter);
} else } else
pci_release_regions(pdev); pci_release_regions(pdev);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册