f2fs: release locks before return in f2fs_ioc_gc_range()
authorQiuyang Sun <sunqiuyang@huawei.com>
Tue, 13 Mar 2018 11:42:50 +0000 (19:42 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sun, 8 Apr 2018 11:14:26 +0000 (04:14 -0700)
Currently, we will leave the kernel with locks still held when the gc_range
is invalid. This patch fixes the bug.

Signed-off-by: Qiuyang Sun <sunqiuyang@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index 5783584cfbe5899d69bc7f6f5ae44b33185df311..13fee9252e1b6aa18d5f938d9624ee6c82be0654 100644 (file)
@@ -2058,8 +2058,10 @@ static int f2fs_ioc_gc_range(struct file *filp, unsigned long arg)
                return ret;
 
        end = range.start + range.len;
-       if (range.start < MAIN_BLKADDR(sbi) || end >= MAX_BLKADDR(sbi))
-               return -EINVAL;
+       if (range.start < MAIN_BLKADDR(sbi) || end >= MAX_BLKADDR(sbi)) {
+               ret = -EINVAL;
+               goto out;
+       }
 do_more:
        if (!range.sync) {
                if (!mutex_trylock(&sbi->gc_mutex)) {