lkml.org 
[lkml]   [2009]   [Apr]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] driver: dont update dev_name if it is not changed

* Yinghai Lu <yinghai@kernel.org> wrote:

> 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.
>
> [Impact: fix corrupted names in /proc/iomem ]
>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>
> ---
> lib/kobject.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> Index: linux-2.6/lib/kobject.c
> ===================================================================
> --- linux-2.6.orig/lib/kobject.c
> +++ linux-2.6/lib/kobject.c
> @@ -216,12 +216,21 @@ int kobject_set_name_vargs(struct kobjec
> va_list vargs)
> {
> const char *old_name = kobj->name;
> + char *new_name;
> char *s;
>
> - kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
> - if (!kobj->name)
> + new_name = kvasprintf(GFP_KERNEL, fmt, vargs);
> + if (!new_name)
> return -ENOMEM;
>
> + /* different ? */
> + if (!strcmp(new_name, old_name)) {
> + kfree(new_name);
> + return 0;
> + }
> +
> + kobj->name = new_name;
> +
> /* ewww... some of these buggers have '/' in the name ... */
> while ((s = strchr(kobj->name, '/')))
> s[0] = '!';

So we used the old name in the resource code, and the kfree() here
corrupted the /proc/iomem output?

This still looks fragile to me ...

Ingo


\
 
 \ /
  Last update: 2009-04-18 22:15    [from the cache]
©2003-2011 Jasper Spaans