Btrfs: dereferencing freed memory
[firefly-linux-kernel-4.4.55.git] / fs / btrfs / ioctl.c
index 2845c6ceecd247f78adcd2b049ea220bbe764ff4..874d36e5f167eb879207fe78b56116f1402868b0 100644 (file)
@@ -48,7 +48,6 @@
 #include "print-tree.h"
 #include "volumes.h"
 #include "locking.h"
-#include "ctree.h"
 
 /* Mask out flags that are inappropriate for the given type of inode. */
 static inline __u32 btrfs_mask_flags(umode_t mode, __u32 flags)
@@ -1375,6 +1374,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp)
                                           sizeof(*range))) {
                                ret = -EFAULT;
                                kfree(range);
+                               goto out;
                        }
                        /* compression requires us to start the IO */
                        if ((range->flags & BTRFS_DEFRAG_RANGE_COMPRESS)) {