reiserfs: deal with NULL xattr root w/ xattrs disabled
authorJeff Mahoney <jeffm@suse.com>
Sun, 17 May 2009 05:02:02 +0000 (01:02 -0400)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 17 May 2009 18:45:45 +0000 (11:45 -0700)
This avoids an Oops in open_xa_root that can occur when deleting a file
with xattrs disabled.  It assumes that the xattr root will be there, and
that is not guaranteed.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/reiserfs/super.c
fs/reiserfs/xattr.c

index 1215a4f50cd2d0c37e5fa3829b4fe95dbc8d0d86..3567fb9e3fb12140988c8909b48e607edd45c98d 100644 (file)
@@ -448,13 +448,11 @@ int remove_save_link(struct inode *inode, int truncate)
 static void reiserfs_kill_sb(struct super_block *s)
 {
        if (REISERFS_SB(s)) {
-#ifdef CONFIG_REISERFS_FS_XATTR
                if (REISERFS_SB(s)->xattr_root) {
                        d_invalidate(REISERFS_SB(s)->xattr_root);
                        dput(REISERFS_SB(s)->xattr_root);
                        REISERFS_SB(s)->xattr_root = NULL;
                }
-#endif
                if (REISERFS_SB(s)->priv_root) {
                        d_invalidate(REISERFS_SB(s)->priv_root);
                        dput(REISERFS_SB(s)->priv_root);
index cf949646dd574136f0d61dc7eff1387b7e2d0a96..628075ca82c1672170e719ec31b46bf72399bf60 100644 (file)
@@ -123,7 +123,9 @@ static struct dentry *open_xa_root(struct super_block *sb, int flags)
        mutex_lock_nested(&privroot->d_inode->i_mutex, I_MUTEX_XATTR);
 
        xaroot = dget(REISERFS_SB(sb)->xattr_root);
-       if (!xaroot->d_inode) {
+       if (!xaroot)
+               xaroot = ERR_PTR(-ENODATA);
+       else if (!xaroot->d_inode) {
                int err = -ENODATA;
                if (xattr_may_create(flags))
                        err = xattr_mkdir(privroot->d_inode, xaroot, 0700);