Commit:     e49452c67703d3647467d65275fb893589384fed
Parent:     cbd9c883696da72b2b1f03f909dbacc04bbf8b58
Author:     Tejun Heo <[EMAIL PROTECTED]>
AuthorDate: Wed Jan 16 12:06:14 2008 +0900
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Wed Jan 16 09:54:03 2008 -0800

    sysfs: make sysfs_lookup() return ERR_PTR(-ENOENT) on failed lookup
    sysfs tries to keep dcache a strict subset of sysfs_dirent tree by
    shooting down dentries when a node is removed, that is, no negative
    dentry for sysfs.  However, the lookup function returned NULL and thus
    created negative dentries when the target node didn't exist.
    Make sysfs_lookup() return ERR_PTR(-ENOENT) on lookup failure.  This
    fixes the NULL dereference bug in sysfs_get_dentry() discovered by
    bluetooth rfcomm device moving around.
    Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
 fs/sysfs/dir.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 3371629..b197016 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -678,8 +678,10 @@ static struct dentry * sysfs_lookup(struct inode *dir, 
struct dentry *dentry,
        sd = sysfs_find_dirent(parent_sd, dentry->;
        /* no such entry */
-       if (!sd)
+       if (!sd) {
+               ret = ERR_PTR(-ENOENT);
                goto out_unlock;
+       }
        /* attach dentry and inode */
        inode = sysfs_get_inode(sd);
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

Reply via email to