lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1344355862-2726-14-git-send-email-jiang.liu@huawei.com>
Date:	Wed,  8 Aug 2012 00:10:53 +0800
From:	Jiang Liu <liuj97@...il.com>
To:	Bjorn Helgaas <bhelgaas@...gle.com>,
	Don Dutile <ddutile@...hat.com>,
	Yinghai Lu <yinghai@...nel.org>,
	Greg KH <gregkh@...uxfoundation.org>,
	Kenji Kaneshige <kaneshige.kenji@...fujitsu.com>
Cc:	Jiang Liu <jiang.liu@...wei.com>,
	Taku Izumi <izumi.taku@...fujitsu.com>,
	"Rafael J . Wysocki" <rjw@...k.pl>,
	Yijing Wang <wangyijing@...wei.com>,
	Xinwei Hu <huxinwei@...wei.com>, linux-kernel@...r.kernel.org,
	linux-pci@...r.kernel.org, Jiang Liu <liuj97@...il.com>
Subject: [RFC PATCH v1 13/22] PCI: make each PCI device hold a reference to its parent PCI bus

Make each PCI device hold a reference to its parent PCI bus, so it won't
cause invalid memory access when doing:
pci_bus_lock_states(dev->bus, PCI_BUS_STATE_xxxx);

Signed-off-by: Jiang Liu <liuj97@...il.com>
---
 drivers/pci/iov.c    |    3 ++-
 drivers/pci/probe.c  |    2 +-
 drivers/pci/remove.c |    1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index c7d2969..40f5f52 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -92,7 +92,8 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
 		kfree(virtfn);
 		mutex_unlock(&iov->dev->sriov->lock);
 		return -ENOMEM;
-	}
+	} else
+		pci_bus_get(virtfn->bus);
 	virtfn->devfn = virtfn_devfn(dev, id);
 	virtfn->vendor = dev->vendor;
 	pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index e6b40d0..47bf071 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1272,7 +1272,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
 	if (!dev)
 		return NULL;
 
-	dev->bus = bus;
+	dev->bus = pci_bus_get(bus);
 	dev->devfn = devfn;
 	dev->vendor = l & 0xffff;
 	dev->device = (l >> 16) & 0xffff;
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index a26a841..0d947c0 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -43,6 +43,7 @@ static void pci_destroy_dev(struct pci_dev *dev)
 		dev->bus_list.next = dev->bus_list.prev = NULL;
 		up_write(&pci_bus_sem);
 		pci_free_resources(dev);
+		pci_bus_put(dev->bus);
 		put_device(&dev->dev);
 	}
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ