From patchwork Sat Apr 18 22:05:45 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 18873 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3IM8VkU000367 for ; Sat, 18 Apr 2009 22:08:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754430AbZDRWIa (ORCPT ); Sat, 18 Apr 2009 18:08:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754330AbZDRWI3 (ORCPT ); Sat, 18 Apr 2009 18:08:29 -0400 Received: from hera.kernel.org ([140.211.167.34]:49258 "EHLO hera.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753870AbZDRWI3 (ORCPT ); Sat, 18 Apr 2009 18:08:29 -0400 Received: from [129.150.16.63] (sca-ea-fw-1.Sun.COM [192.18.43.225]) (authenticated bits=0) by hera.kernel.org (8.14.2/8.13.8) with ESMTP id n3IM5nPK030897 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 18 Apr 2009 22:05:49 GMT Message-ID: <49EA4EB9.2030307@kernel.org> Date: Sat, 18 Apr 2009 15:05:45 -0700 From: Yinghai Lu User-Agent: Thunderbird 2.0.0.19 (X11/20081227) MIME-Version: 1.0 To: Ingo Molnar , Kay Sievers , Greg KH , Linus Torvalds CC: Jesse Barnes , Andrew Morton , "H. Peter Anvin" , Thomas Gleixner , "linux-kernel@vger.kernel.org" , linux-pci@vger.kernel.org Subject: [PATCH] driver: dont update dev_name via device_add path References: <20090416235452.GE21405@elte.hu> <20090417131633.GA30578@elte.hu> <49E8FD0B.2050308@zytor.com> <49E96731.1000501@kernel.org> <49EA27B9.3030004@kernel.org> <20090418192314.GA22107@suse.de> <1240086446.2411.9.camel@poy> <20090418203718.GD30144@elte.hu> In-Reply-To: <20090418203718.GD30144@elte.hu> X-Virus-Scanned: ClamAV 0.93.3/9255/Sat Apr 18 12:31:15 2009 on hera.kernel.org X-Virus-Status: Clean Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Kay Sievers notice one system /proc/iomem some entries missed the name for pci_devices it turns that dev->dev.kobj name is changed after device_add. for pci code: via acpi_pci_root_driver.ops.add (aka acpi_pci_root_add) ==> pci_acpi_scan_root is used to scan pci bus/device, and at the same time we read the resource for pci_dev in the pci_read_bases, we have res->name = pci_name(pci_dev); pci_name is calling dev_name. later via acpi_pci_root_driver.ops.start (aka acpi_pci_root_start) ==> pci_bus_add_device to add all pci_dev in kobj tree. pci_bus_add_device will call device_add. actually in device_add /* first, register with generic layer. */ error = kobject_add(&dev->kobj, dev->kobj.parent, "%s", dev_name(dev)); if (error) goto Error; will get one new name for that kobj, old name is freed. [Impact: fix corrupted names in /proc/iomem ] Signed-off-by: Yinghai Lu --- drivers/base/core.c | 3 ++- lib/kobject.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/base/core.c =================================================================== --- linux-2.6.orig/drivers/base/core.c +++ linux-2.6/drivers/base/core.c @@ -891,7 +891,8 @@ int device_add(struct device *dev) set_dev_node(dev, dev_to_node(parent)); /* first, register with generic layer. */ - error = kobject_add(&dev->kobj, dev->kobj.parent, "%s", dev_name(dev)); + /* we require the name to be set before, and pass NULL */ + error = kobject_add(&dev->kobj, dev->kobj.parent, NULL); if (error) goto Error; Index: linux-2.6/lib/kobject.c =================================================================== --- linux-2.6.orig/lib/kobject.c +++ linux-2.6/lib/kobject.c @@ -218,6 +218,9 @@ int kobject_set_name_vargs(struct kobjec const char *old_name = kobj->name; char *s; + if (kobj->name && !fmt) + return 0; + kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs); if (!kobj->name) return -ENOMEM;