ia64/topology.c: exit cache_add_dev when kobject_init_and_add fails
PATCH 1/1 ia64/topology.c: exit cache_add_dev when kobject_init_and_add fails
make cache_add_dev exit sysfs when kobject_init_and_add returns an error.
Signed-off-by Xiaotian Feng <[email protected]>
--- arch/ia64/kernel/topology.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
arch/ia64/kernel/topology.c +4 -0
@@ -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);
Signature · 1 line
1.6.2.5
Quoted 13 lines · Xiaotian Feng
make
cache_add_devexit sysfs whenkobject_init_and_addreturns an error.Signed-off-by Xiaotian Feng <[email protected]>--- arch/ia64/kernel/topology.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)arch/ia64/kernel/topology.c +0
-0
arch/ia64/kernel/topology.c static int __cpuinit cache_add_dev(struct sys_device * sys_dev) · line 381
Quoted 10 lines
arch/ia64/kernel/topology.c +4
-0@@ -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 <[email protected]>
Signed-off-by Fenghua Yu <[email protected]>
--- arch/ia64/kernel/topology.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletion(-)
arch/ia64/kernel/topology.c +5 -1
@@ -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 ); }