Re: [PATCH 5/7] pci hotplug core: add check of duplicate slot name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 27 May 2008 19:07:01 +0900
Kenji Kaneshige <kaneshige.kenji@xxxxxxxxxxxxxx> wrote:

> Fix the following errors reported by Jan C. Nordholz in
> http://bugzilla.kernel.org/show_bug.cgi?id=10751.
> 
> kobject_add_internal failed for 2 with -EEXIST, don't try to register things with the same name in the same directory.
> Pid: 1, comm: swapper Tainted: G        W 2.6.26-rc3 #1
>  [<c0266980>] kobject_add_internal+0x140/0x190
>  [<c0266afd>] kobject_init_and_add+0x2d/0x40
>  [<c027bc91>] pci_hp_register+0x81/0x2f0
>  [<c027fd07>] pciehp_probe+0x1a7/0x470
>  [<c01b3b84>] sysfs_add_one+0x44/0xa0
>  [<c01b3c1f>] sysfs_addrm_start+0x3f/0xb0
>  [<c01b497a>] sysfs_create_link+0x8a/0xf0
>  [<c0279570>] pcie_port_probe_service+0x50/0x80
>  [<c02e0545>] driver_sysfs_add+0x55/0x70
>  [<c02e0662>] driver_probe_device+0x82/0x180
>  [<c02e07cc>] __driver_attach+0x6c/0x70
>  [<c02dfe0a>] bus_for_each_dev+0x3a/0x60
>  [<c05db2d0>] pcied_init+0x0/0x80
>  [<c02e04e6>] driver_attach+0x16/0x20
>  [<c02e0760>] __driver_attach+0x0/0x70
>  [<c02e0341>] bus_add_driver+0x1a1/0x220
>  [<c05db2d0>] pcied_init+0x0/0x80
>  [<c02e09cd>] driver_register+0x4d/0x120
>  [<c05db050>] ibm_acpiphp_init+0x0/0x190
>  [<c0125aab>] printk+0x1b/0x20
>  [<c05db2d0>] pcied_init+0x0/0x80
>  [<c05db2de>] pcied_init+0xe/0x80
>  [<c05c751a>] kernel_init+0x10a/0x300
>  [<c0120138>] schedule_tail+0x18/0x50
>  [<c0103b9a>] ret_from_fork+0x6/0x1c
>  [<c05c7410>] kernel_init+0x0/0x300
>  [<c05c7410>] kernel_init+0x0/0x300
>  [<c010485b>] kernel_thread_helper+0x7/0x1c
>  =======================
> pci_hotplug: Unable to register kobject '2'<3>pciehp: pci_hp_register failed with error -22

Did we fix the missing \n?

--- a/drivers/pci/hotplug/pci_hotplug_core.c~a
+++ a/drivers/pci/hotplug/pci_hotplug_core.c
@@ -635,7 +635,7 @@ int pci_hp_register (struct hotplug_slot
 	result = kobject_init_and_add(&slot->kobj, &hotplug_slot_ktype, NULL,
 				      "%s", slot->name);
 	if (result) {
-		err("Unable to register kobject '%s'", slot->name);
+		err("Unable to register kobject '%s'\n", slot->name);
 		return -EINVAL;
 	}
 
_

> 
> Slot with the same name can be registered multiple times if shpchp or
> pciehp driver is loaded after acpiphp is loaded because ACPI based
> hotplug driver and Native OS hotplug driver trying to handle the same
> physical slot. In this case, current pci_hotplug core will call
> kobject_init_and_add() muliple time with the same name. This is the
> cause of this problem. To fix this problem, this patch adds the check
> into pci_hp_register() to see if the slot with the same name.
> 
> Signed-off-by: Kenji Kaneshige <kaneshige.kenji@xxxxxxxxxxxxxx>
> 
> ---
>  drivers/pci/hotplug/pci_hotplug_core.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> Index: linux-2.6.26-rc4/drivers/pci/hotplug/pci_hotplug_core.c
> ===================================================================
> --- linux-2.6.26-rc4.orig/drivers/pci/hotplug/pci_hotplug_core.c
> +++ linux-2.6.26-rc4/drivers/pci/hotplug/pci_hotplug_core.c
> @@ -619,6 +619,7 @@ static struct hotplug_slot *get_slot_fro
>  int pci_hp_register (struct hotplug_slot *slot)
>  {
>  	int result;
> +	struct hotplug_slot *tmp;
>  
>  	if (slot == NULL)
>  		return -ENODEV;
> @@ -630,7 +631,11 @@ int pci_hp_register (struct hotplug_slot
>  		return -EINVAL;
>  	}
>  
> -	/* this can fail if we have already registered a slot with the same name */
> +	/* Check if we have already registered a slot with the same name. */
> +	tmp = get_slot_from_name(slot->name);
> +	if (tmp)
> +		return -EEXIST;
> +

Please avoid adding variables called `tmp' or `temp' or such.  In this
case

	if (get_slot_from_name(slot->name))
		return -EEXIST;

would suit.


I assume these patches will destroy Alex's frequently-destroyed
pci-hotplug-introduce-pci_slot.patch.  Ho hum.

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux