From: Chao Yu Date: Fri, 27 Jun 2025 02:38:17 +0000 (+0800) Subject: f2fs: fix to check upper boundary for gc_valid_thresh_ratio X-Git-Tag: v6.16.1~149 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=54c4ee25939e73cee77090f636810679cdb348f0;p=thirdparty%2Fkernel%2Fstable.git f2fs: fix to check upper boundary for gc_valid_thresh_ratio [ Upstream commit 7a96d1d73ce9de5041e891a623b722f900651561 ] This patch adds missing upper boundary check while setting gc_valid_thresh_ratio via sysfs. Fixes: e791d00bd06c ("f2fs: add valid block ratio not to do excessive GC for one time GC") Cc: Daeho Jeong Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index d0ec9963ff1b3..173ad1a727466 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -635,6 +635,13 @@ out: return count; } + if (!strcmp(a->attr.name, "gc_valid_thresh_ratio")) { + if (t > 100) + return -EINVAL; + *ui = (unsigned int)t; + return count; + } + #ifdef CONFIG_F2FS_IOSTAT if (!strcmp(a->attr.name, "iostat_enable")) { sbi->iostat_enable = !!t;