Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e7b0d26a86943370c04d6833c6edba2a72a6e240
Commit:     e7b0d26a86943370c04d6833c6edba2a72a6e240
Parent:     d9a9cdfb078d755e648d53ec25b7370f84ee5729
Author:     Alan Stern <[EMAIL PROTECTED]>
AuthorDate: Thu Mar 15 15:51:28 2007 -0400
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Thu Mar 15 15:29:26 2007 -0700

    [PATCH] sysfs: reinstate exclusion between method calls and attribute 
unregistration
    
    This patch (as869) reinstates the mutual exclusion between sysfs
    attribute method calls and attribute unregistration.  The
    previously-reported deadlocks have been fixed, and this exclusion is
    by far the simplest way to avoid races during driver unbinding.
    
    The check for orphaned read-buffers has been moved down slightly, so
    that the remainder of a partially-read buffer will still be available
    to userspace even after the attribute has been unregistered.
    
    Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
    Cc: Hugh Dickins <[EMAIL PROTECTED]>
    Cc: Cornelia Huck <[EMAIL PROTECTED]>
    Cc: Oliver Neukum <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/sysfs/file.c  |   10 +++++-----
 fs/sysfs/inode.c |   10 +++++++---
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 1bafdf6..fc46333 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -168,12 +168,12 @@ sysfs_read_file(struct file *file, char __user *buf, 
size_t count, loff_t *ppos)
        ssize_t retval = 0;
 
        down(&buffer->sem);
-       if (buffer->orphaned) {
-               retval = -ENODEV;
-               goto out;
-       }
        if (buffer->needs_read_fill) {
-               if ((retval = fill_read_buffer(file->f_path.dentry,buffer)))
+               if (buffer->orphaned)
+                       retval = -ENODEV;
+               else
+                       retval = fill_read_buffer(file->f_path.dentry,buffer);
+               if (retval)
                        goto out;
        }
        pr_debug("%s: count = %zd, ppos = %lld, buf = %s\n",
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index ccb7d72..4de5c6b 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -222,13 +222,17 @@ const unsigned char * sysfs_get_name(struct sysfs_dirent 
*sd)
 
 static inline void orphan_all_buffers(struct inode *node)
 {
-       struct sysfs_buffer_collection *set = node->i_private;
+       struct sysfs_buffer_collection *set;
        struct sysfs_buffer *buf;
 
        mutex_lock_nested(&node->i_mutex, I_MUTEX_CHILD);
-       if (node->i_private) {
-               list_for_each_entry(buf, &set->associates, associates)
+       set = node->i_private;
+       if (set) {
+               list_for_each_entry(buf, &set->associates, associates) {
+                       down(&buf->sem);
                        buf->orphaned = 1;
+                       up(&buf->sem);
+               }
        }
        mutex_unlock(&node->i_mutex);
 }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to