Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: release locks before return in f2fs_ioc_gc_range()

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>

authored by

Qiuyang Sun and committed by
Jaegeuk Kim
da5ce874 bb1105e4

+4 -2
+4 -2
fs/f2fs/file.c
··· 2059 2059 return ret; 2060 2060 2061 2061 end = range.start + range.len; 2062 - if (range.start < MAIN_BLKADDR(sbi) || end >= MAX_BLKADDR(sbi)) 2063 - return -EINVAL; 2062 + if (range.start < MAIN_BLKADDR(sbi) || end >= MAX_BLKADDR(sbi)) { 2063 + ret = -EINVAL; 2064 + goto out; 2065 + } 2064 2066 do_more: 2065 2067 if (!range.sync) { 2066 2068 if (!mutex_trylock(&sbi->gc_mutex)) {