aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/segment.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2014-10-21 08:07:33 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2014-11-03 19:07:35 -0500
commit9bd27ae4aafc9bfee6c8791f7d801ea16cc5622b (patch)
treee88cfd25c5552cf04b61930a803635220fcd64cb /fs/f2fs/segment.c
parentd64948a4df9f5571b0efa81f71a59bc86d7056a7 (diff)
f2fs: avoid returning uninitialized value to userspace from f2fs_trim_fs()
If user specifies too low end sector for trimming, f2fs_trim_fs() will use uninitialized value as a number of trimmed blocks and returns it to userspace. Initialize number of trimmed blocks early to avoid the problem. Coverity-id: 1248809 CC: stable@vger.kernel.org Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r--fs/f2fs/segment.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 2c1e60893ef2..6b0850487aa2 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1032,6 +1032,7 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
1032 range->len < sbi->blocksize) 1032 range->len < sbi->blocksize)
1033 return -EINVAL; 1033 return -EINVAL;
1034 1034
1035 cpc.trimmed = 0;
1035 if (end <= MAIN_BLKADDR(sbi)) 1036 if (end <= MAIN_BLKADDR(sbi))
1036 goto out; 1037 goto out;
1037 1038
@@ -1043,7 +1044,6 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
1043 cpc.trim_start = start_segno; 1044 cpc.trim_start = start_segno;
1044 cpc.trim_end = end_segno; 1045 cpc.trim_end = end_segno;
1045 cpc.trim_minlen = range->minlen >> sbi->log_blocksize; 1046 cpc.trim_minlen = range->minlen >> sbi->log_blocksize;
1046 cpc.trimmed = 0;
1047 1047
1048 /* do checkpoint to issue discard commands safely */ 1048 /* do checkpoint to issue discard commands safely */
1049 write_checkpoint(sbi, &cpc); 1049 write_checkpoint(sbi, &cpc);