Btrfs: Make sure dir is non-null before doing S_ISGID checks

The S_ISGID check in btrfs_new_inode caused an oops during subvol creation
because sometimes the dir is null.

Signed-off-by: Chris Mason <chris.mason@oracle.com>

+1 -1
+1 -1
fs/btrfs/inode.c
··· 3491 3492 inode->i_uid = current_fsuid(); 3493 3494 - if (dir->i_mode & S_ISGID) { 3495 inode->i_gid = dir->i_gid; 3496 if (S_ISDIR(mode)) 3497 mode |= S_ISGID;
··· 3491 3492 inode->i_uid = current_fsuid(); 3493 3494 + if (dir && (dir->i_mode & S_ISGID)) { 3495 inode->i_gid = dir->i_gid; 3496 if (S_ISDIR(mode)) 3497 mode |= S_ISGID;