Re: 2.6.17-mm6

From: Sergey Vlasov
Date: Mon Jul 03 2006 - 08:28:37 EST


On Mon, 03 Jul 2006 23:00:34 +1200 Reuben Farrelly wrote:

> Allocate Port Service[0000:00:1c.0:pcie0]
> Allocate Port Service[0000:00:1c.0:pcie0]
> kobject_add failed for 0000:00:1c.0:pcie0 with -EEXIST, don't try to register
> things with the same name in the same directory.

These names are truncated - they should end with two hex digits:

snprintf(device->bus_id, sizeof(device->bus_id), "%s:pcie%02x",
pci_name(parent), get_descriptor_id(port_type, service_type));

Names were truncated at 18 characters, but sizeof(device->bus_id) is 20
currently, so these names should just fit there. I see that snprintf()
was changed recently - maybe there is some off-by-one bug there?

And if you want, you can blame me for such long names:

commit 8c9ad508c8737ca46a4c55b1062d159b86f7cee2
Author: Sergey Vlasov <vsu@xxxxxxxxxxx>
Date: Mon Nov 14 20:30:50 2005 +0300

[PATCH] PCIE: make bus_id for PCI Express devices unique

The bus_id string must be unique for all devices of that bus in the
system, not just for devices with the same parent - otherwise multiple
symlinks with identical names appear in /sys/bus/pci_express/devices.

Signed-off-by: Sergey Vlasov <vsu@xxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 467a4ce..e4e5f1e 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -238,8 +238,8 @@ static void pcie_device_init(struct pci_
device->driver = NULL;
device->driver_data = NULL;
device->release = release_pcie_device; /* callback to free pcie dev */
- sprintf(&device->bus_id[0], "pcie%02x",
- get_descriptor_id(port_type, service_type));
+ snprintf(device->bus_id, sizeof(device->bus_id), "%s:pcie%02x",
+ pci_name(parent), get_descriptor_id(port_type, service_type));
device->parent = &parent->dev;
}


Attachment: pgp00000.pgp
Description: PGP signature