diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 055495008c6c..db0659c3c740 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2059,6 +2059,12 @@ static int f2fs_ioc_defragment(struct file *filp, unsigned long arg) goto out; } + if (unlikely((range.start + range.len) >> PAGE_SHIFT > + sbi->max_file_blocks)) { + err = -EINVAL; + goto out; + } + err = f2fs_defragment_range(sbi, filp, &range); f2fs_update_time(sbi, REQ_TIME); if (err < 0)