diff mbox

[1/3] Fix updating of named attribute groups

Message ID 20091020054946.GD29158@parisc-linux.org (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Matthew Wilcox Oct. 20, 2009, 5:49 a.m. UTC
None
diff mbox

Patch

diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index fe61194..0c4d342 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -69,12 +69,19 @@  static int internal_create_group(struct kobject *kobj, int update,
 		return -EINVAL;
 
 	if (grp->name) {
-		error = sysfs_create_subdir(kobj, grp->name, &sd);
-		if (error)
-			return error;
-	} else
-		sd = kobj->sd;
-	sysfs_get(sd);
+		if (update) {
+			sd = sysfs_get_dirent(kobj->sd, grp->name);
+			if (!sd)
+				return -ENOENT;
+		} else {
+			error = sysfs_create_subdir(kobj, grp->name, &sd);
+			if (error)
+				return error;
+			sysfs_get(sd);
+		}
+	} else {
+		sd = sysfs_get(kobj->sd);
+	}
 	error = create_files(sd, kobj, grp, update);
 	if (error) {
 		if (grp->name)