[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20091020054946.GD29158@parisc-linux.org>
Date: Mon, 19 Oct 2009 23:49:46 -0600
From: Matthew Wilcox <matthew@....cx>
To: Greg Kroah-Hartman <gregkh@...e.de>
Cc: linux-kernel@...r.kernel.org,
Jesse Barnes <jbarnes@...tuousgeek.org>,
linux-pci@...r.kernel.org
Subject: [PATCH 1/3] Fix updating of named attribute groups
From: Matthew Wilcox <willy@...ux.intel.com>
Date: Sat, 17 Oct 2009 15:47:43 -0400
Subject: [PATCH 1/3] Fix updating of named attribute groups
The current code tries to create a subdirectory, even if the caller is
trying to update an existing group. If the caller wants to update a named
group, we need to call sysfs_get_dirent() which bumps the reference count
on the dirent, so move the sysfs_get() into the other two arms of the 'if'.
Signed-off-by: Matthew Wilcox <willy@...ux.intel.com>
---
fs/sysfs/group.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
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)
--
1.6.3.3
--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
--
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