commit d6ddf55440833fd9404138026af246c51ebeef22
tree 095984ba56a4f6eb14379f77bc6b0fbd49cf7f6a
parent 4c1b6d18bf2fdeb5ac725126c6928aaa98c8e22f
author Eric Sandeen <[EMAIL PROTECTED]> 1163668762 -0800
committer Linus Torvalds <[EMAIL PROTECTED]> 1163706218 -0800

[PATCH] hfs_fill_super returns success even if no root inode

mount that image...
fs: filesystem was not cleanly unmounted, running fsck.hfs is recommended.  
mounting read-only.
hfs: get root inode failed.
BUG: unable to handle kernel NULL pointer dereference at virtual address 
 printing eip
EIP is at superblock_doinit+0x21/0x767
 [] selinux_sb_kern_mount+0xc/0x4b
 [] vfs_kern_mount+0x99/0xf6
 [] do_kern_mount+0x2d/0x3e
 [] do_mount+0x5fa/0x66d
 [] sys_mount+0x77/0xae
 [] syscall_call+0x7/0xb
DWARF2 unwinder stuck at syscall_call+0x7/0xb

hfs_fill_super() returns success even if
  root_inode = hfs_iget(sb, &fd.search_key->cat, &rec);
  sb->s_root = d_alloc_root(root_inode);

fails.  This superblock finds its way to superblock_doinit() which does:

        struct dentry *root = sb->s_root;
        struct inode *inode = root->d_inode;

and boom.  Need to make sure the error cases return an error, I think.

[EMAIL PROTECTED]: return -ENOMEM on oom]
Signed-off-by: Eric Sandeen <[EMAIL PROTECTED]>
Cc: Roman Zippel <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>

 fs/hfs/super.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index d43b4fc..85b17b3 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -390,11 +390,13 @@ static int hfs_fill_super(struct super_b
                goto bail_no_root;
+       res = -EINVAL;
        root_inode = hfs_iget(sb, &fd.search_key->cat, &rec);
        if (!root_inode)
                goto bail_no_root;
+       res = -ENOMEM;
        sb->s_root = d_alloc_root(root_inode);
        if (!sb->s_root)
                goto bail_iput;
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