[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070716135230.GC2040@APFDCB5C>
Date: Mon, 16 Jul 2007 22:52:30 +0900
From: Akinobu Mita <akinobu.mita@...il.com>
To: linux-kernel@...r.kernel.org, Greg Kroah-Hartman <gregkh@...e.de>
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@...e.de>
Signed-off-by: Akinobu Mita <akinobu.mita@...il.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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists