Zhiguo Niu 0070565082 f2fs: fix to do sanity check in update_sit_entry
[ Upstream commit 36959d18c3cf09b3c12157c6950e18652067de77 ]

If GET_SEGNO return NULL_SEGNO for some unecpected case,
update_sit_entry will access invalid memory address,
cause system crash. It is better to do sanity check about
GET_SEGNO just like update_segment_mtime & locate_dirty_segment.

Also remove some redundant judgment code.

Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 3c2c864f19490da6e892290441ba7dcc7bae2576)
[Vegard: drop hunk in {f2fs_,}allocate_data_block due to missing commit
 65f1b80b33378501ea552ef085e9c31739af356c ('Revert "f2fs: handle dirty
 segments inside refresh_sit_entry"') -- the important part of the patch
 is the addition of the segno check.]
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
2024-10-24 10:07:38 +00:00
..
2020-01-17 19:45:52 +01:00