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>
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index ddb0f0e..8f07062 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c
@@ -3491,7 +3491,7 @@ inode->i_uid = current_fsuid(); - if (dir->i_mode & S_ISGID) { + if (dir && (dir->i_mode & S_ISGID)) { inode->i_gid = dir->i_gid; if (S_ISDIR(mode)) mode |= S_ISGID;