[PATCH] sysfs-fixes:

From: yanyg
Date: Tue Jan 15 2013 - 22:25:15 EST


@sysfs_update_group@ always fail and generates WARNING CALL trace.
fix @internal_create_group@ to avoid it.
---
fs/sysfs/group.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 2df555c..51fcf62 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -60,7 +60,7 @@ static int internal_create_group(struct kobject *kobj, int update,
const struct attribute_group *grp)
{
struct sysfs_dirent *sd;
- int error;
+ int error, do_put = 0;

BUG_ON(!kobj || (!update && !kobj->sd));

@@ -73,9 +73,14 @@ 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;
+ sd = sysfs_get_dirent(kobj->sd, NULL, grp->name);
+ if (sd) {
+ do_put = 1;
+ } else {
+ error = sysfs_create_subdir(kobj, grp->name, &sd);
+ if (error)
+ return error;
+ }
} else
sd = kobj->sd;
sysfs_get(sd);
@@ -85,6 +90,7 @@ static int internal_create_group(struct kobject *kobj, int update,
sysfs_remove_subdir(sd);
}
sysfs_put(sd);
+ if (do_put) sysfs_put(sd);
return error;
}

--
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/