lkml.org 
[lkml]   [2007]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 3/10] sysfs: fix error handling in create_files()
Current error handling in create_files() attempts to remove
all attributes passed by argument by remove_files(). But it should
only remove the attributes that have been successfully added.

Cc: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

---
fs/sysfs/group.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)

Index: 2.6-mm/fs/sysfs/group.c
===================================================================
--- 2.6-mm.orig/fs/sysfs/group.c
+++ 2.6-mm/fs/sysfs/group.c
@@ -30,13 +30,19 @@ static void remove_files(struct sysfs_di
static int create_files(struct sysfs_dirent *dir_sd,
const struct attribute_group *grp)
{
- struct attribute *const* attr;
- int error = 0;
+ int i;
+ int error;
+
+ for (i = 0; grp->attrs[i]; i++) {
+ error = sysfs_add_file(dir_sd, grp->attrs[i], SYSFS_KOBJ_ATTR);
+ if (error)
+ goto error;
+ }
+ return 0;
+error:
+ while (i--)
+ sysfs_hash_and_remove(dir_sd, grp->attrs[i]->name);

- for (attr = grp->attrs; *attr && !error; attr++)
- error = sysfs_add_file(dir_sd, *attr, SYSFS_KOBJ_ATTR);
- if (error)
- remove_files(dir_sd, grp);
return error;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2007-07-16 16:07    [W:0.153 / U:1.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site