[lkml]   [2008]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[PATCH 2.6.26] PCI: refuse to re-add a device to a bus upon pci_scan_child_bus()
    Dear Penguins,

    As a follow up on my own post ( ), I
    have solved a small bug/misbehavior within the pci_scan_single_device().

    The misbehavior manifest itself upon calling pci_scan_child_bus() with a
    bus which already contain some devices. After scanning is done devices
    that already existed will be present twice in the PCI bus devise list.
    Once with is_added indication and once without. Trying to add this bus
    will cause a resource conflict as the same device is already present and

    This patch will simply prevent a device to be added to a pci bus list if
    it is already there.

    Points to consider:
    1. I am not a PCI Guru and might have over looked the bigger picture. Is
    it OK to prevent a device of being re-added?
    2. I have decided that two devices are, in fact, the same instance if it
    has the same: vendor, device, and devfn. Is there a finer test for a
    device identity?

    p.s. As per it is
    preferred for Mozilla Firefox clients to attach the patch, hence my
    patch is attached.


    Signed-off-by: Eran Liberty <>

    drivers/pci/probe.c | 10 ++++++++++
    1 files changed, 10 insertions(+), 0 deletions(-)

    diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
    index b1724cf..e3c3ee0 100644
    --- a/drivers/pci/probe.c
    +++ b/drivers/pci/probe.c
    @@ -1002,11 +1002,21 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
    struct pci_dev *__ref pci_scan_single_device(struct pci_bus *bus, int devfn)
    struct pci_dev *dev;
    + struct list_head *ln;

    dev = pci_scan_device(bus, devfn);
    if (!dev)
    return NULL;

    + /* refuse to re-add a device */
    + list_for_each(ln, &bus->devices) {
    + struct pci_dev *d = pci_dev_b(ln);
    + if ((d->vendor == dev->vendor) &&
    + (d->device == dev->device) &&
    + (d->devfn == dev->devfn))
    + return NULL;
    + }
    pci_device_add(dev, bus);

    return dev;
     \ /
      Last update: 2008-07-21 21:25    [W:0.118 / U:181.664 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site