Pārlūkot izejas kodu

Btrfs: fix oops when btrfs_inherit_iflags called with a NULL dir

This happens during subvol creation.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
Chris Mason 16 gadi atpakaļ
vecāks
revīzija
0b4dcea579
1 mainītis faili ar 6 papildinājumiem un 1 dzēšanām
  1. 6 1
      fs/btrfs/ioctl.c

+ 6 - 1
fs/btrfs/ioctl.c

@@ -112,7 +112,12 @@ void btrfs_update_iflags(struct inode *inode)
  */
 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir)
 {
-	unsigned int flags = BTRFS_I(dir)->flags;
+	unsigned int flags;
+
+	if (!dir)
+		return;
+
+	flags = BTRFS_I(dir)->flags;
 
 	if (S_ISREG(inode->i_mode))
 		flags &= ~BTRFS_INODE_DIRSYNC;