All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fenghua Yu <fenghua.yu@intel.com>
To: Xiaotian Feng <dfeng@redhat.com>
Cc: "Luck, Tony" <tony.luck@intel.com>,
	"Yu, Fenghua" <fenghua.yu@intel.com>,
	"linux-ia64@vger.kernel.org" <linux-ia64@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ia64/topology.c: exit cache_add_dev when kobject_init_and_add fails
Date: Fri, 24 Jul 2009 17:40:25 +0000	[thread overview]
Message-ID: <20090724174025.GA6568@linux-os.sc.intel.com> (raw)
In-Reply-To: <1248427228-30901-1-git-send-email-dfeng@redhat.com>

On Fri, Jul 24, 2009 at 02:20:28AM -0700, Xiaotian Feng wrote:
> make cache_add_dev exit sysfs when kobject_init_and_add returns an
> error.
> 
> Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
> ---
>  arch/ia64/kernel/topology.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
> index bc80dff..82c5a8f 100644
> --- a/arch/ia64/kernel/topology.c
> +++ b/arch/ia64/kernel/topology.c
> @@ -372,6 +372,10 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
>         retval = kobject_init_and_add(&all_cpu_cache_info[cpu].kobj,
>                                       &cache_ktype_percpu_entry, &sys_dev->kobj,
>                                       "%s", "cache");
> +       if (retval < 0) {
> +               cpu_cache_sysfs_exit(cpu);
> +               return retval;
> +       }
> 
>         for (i = 0; i < all_cpu_cache_info[cpu].num_cache_leaves; i++) {
>                 this_object = LEAF_KOBJECT_PTR(cpu,i);

I add another related failure handling change on top of your patch. Without the
change, kobject_uevent(&all_cpu_cache_info[cpu].kobj, KOBJ_ADD) is still
executed even when previous kobject_init_adn_add failure.

Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>

---
 arch/ia64/kernel/topology.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index bc80dff..8f06035 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -372,6 +372,10 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
 	retval = kobject_init_and_add(&all_cpu_cache_info[cpu].kobj,
 				      &cache_ktype_percpu_entry, &sys_dev->kobj,
 				      "%s", "cache");
+	if (unlikely(retval < 0)) {
+		cpu_cache_sysfs_exit(cpu);
+		return retval;
+	}
 
 	for (i = 0; i < all_cpu_cache_info[cpu].num_cache_leaves; i++) {
 		this_object = LEAF_KOBJECT_PTR(cpu,i);
@@ -385,7 +389,7 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
 			}
 			kobject_put(&all_cpu_cache_info[cpu].kobj);
 			cpu_cache_sysfs_exit(cpu);
-			break;
+			return retval;
 		}
 		kobject_uevent(&(this_object->kobj), KOBJ_ADD);
 	}

WARNING: multiple messages have this Message-ID (diff)
From: Fenghua Yu <fenghua.yu@intel.com>
To: Xiaotian Feng <dfeng@redhat.com>
Cc: "Luck, Tony" <tony.luck@intel.com>,
	"Yu, Fenghua" <fenghua.yu@intel.com>,
	"linux-ia64@vger.kernel.org" <linux-ia64@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ia64/topology.c: exit cache_add_dev when kobject_init_and_add fails
Date: Fri, 24 Jul 2009 10:40:25 -0700	[thread overview]
Message-ID: <20090724174025.GA6568@linux-os.sc.intel.com> (raw)
In-Reply-To: <1248427228-30901-1-git-send-email-dfeng@redhat.com>

On Fri, Jul 24, 2009 at 02:20:28AM -0700, Xiaotian Feng wrote:
> make cache_add_dev exit sysfs when kobject_init_and_add returns an
> error.
> 
> Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
> ---
>  arch/ia64/kernel/topology.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
> index bc80dff..82c5a8f 100644
> --- a/arch/ia64/kernel/topology.c
> +++ b/arch/ia64/kernel/topology.c
> @@ -372,6 +372,10 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
>         retval = kobject_init_and_add(&all_cpu_cache_info[cpu].kobj,
>                                       &cache_ktype_percpu_entry, &sys_dev->kobj,
>                                       "%s", "cache");
> +       if (retval < 0) {
> +               cpu_cache_sysfs_exit(cpu);
> +               return retval;
> +       }
> 
>         for (i = 0; i < all_cpu_cache_info[cpu].num_cache_leaves; i++) {
>                 this_object = LEAF_KOBJECT_PTR(cpu,i);

I add another related failure handling change on top of your patch. Without the
change, kobject_uevent(&all_cpu_cache_info[cpu].kobj, KOBJ_ADD) is still
executed even when previous kobject_init_adn_add failure.

Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>

---
 arch/ia64/kernel/topology.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index bc80dff..8f06035 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -372,6 +372,10 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
 	retval = kobject_init_and_add(&all_cpu_cache_info[cpu].kobj,
 				      &cache_ktype_percpu_entry, &sys_dev->kobj,
 				      "%s", "cache");
+	if (unlikely(retval < 0)) {
+		cpu_cache_sysfs_exit(cpu);
+		return retval;
+	}
 
 	for (i = 0; i < all_cpu_cache_info[cpu].num_cache_leaves; i++) {
 		this_object = LEAF_KOBJECT_PTR(cpu,i);
@@ -385,7 +389,7 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
 			}
 			kobject_put(&all_cpu_cache_info[cpu].kobj);
 			cpu_cache_sysfs_exit(cpu);
-			break;
+			return retval;
 		}
 		kobject_uevent(&(this_object->kobj), KOBJ_ADD);
 	}

  reply	other threads:[~2009-07-24 17:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-24  9:20 [PATCH] ia64/topology.c: exit cache_add_dev when kobject_init_and_add fails Xiaotian Feng
2009-07-24  9:20 ` Xiaotian Feng
2009-07-24 17:40 ` Fenghua Yu [this message]
2009-07-24 17:40   ` Fenghua Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090724174025.GA6568@linux-os.sc.intel.com \
    --to=fenghua.yu@intel.com \
    --cc=dfeng@redhat.com \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.