From: Matthew Wilcox <matthew@wil.cx>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: linux-kernel@vger.kernel.org,
Jesse Barnes <jbarnes@virtuousgeek.org>,
linux-pci@vger.kernel.org
Subject: [PATCH 1/3] Fix updating of named attribute groups
Date: Mon, 19 Oct 2009 23:49:46 -0600 [thread overview]
Message-ID: <20091020054946.GD29158@parisc-linux.org> (raw)
In-Reply-To: <20091020054740.GC29158@parisc-linux.org>
From: Matthew Wilcox <willy@linux.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@linux.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."
next prev parent reply other threads:[~2009-10-20 5:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-20 5:47 [PATCH 0/3] Allow sysfs to be dynamically populated Matthew Wilcox
2009-10-20 5:49 ` Matthew Wilcox [this message]
2009-10-29 15:59 ` [PATCH 1/3] Fix updating of named attribute groups Tejun Heo
2009-10-29 16:19 ` Matthew Wilcox
2009-10-29 16:24 ` Tejun Heo
2009-10-20 5:50 ` [PATCH 2/3] Sysfs: Allow directories to be populated dynamically Matthew Wilcox
2009-10-29 16:20 ` Tejun Heo
2009-10-29 16:21 ` Matthew Wilcox
2009-10-29 16:28 ` Tejun Heo
2009-10-29 19:24 ` Matthew Wilcox
2009-10-30 10:17 ` Tejun Heo
2009-10-30 11:14 ` Matthew Wilcox
2009-10-30 16:06 ` Tejun Heo
2009-10-20 5:50 ` [PATCH 3/3] Expose MSI-X interrupts through a dynamically generated sysfs directory Matthew Wilcox
2009-10-20 8:14 ` Américo Wang
2009-10-20 8:26 ` Matthew Wilcox
2009-10-27 17:32 ` Greg KH
2009-10-20 5:52 ` [PATCH 0/3] Allow sysfs to be dynamically populated Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091020054946.GD29158@parisc-linux.org \
--to=matthew@wil.cx \
--cc=gregkh@suse.de \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.