mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 09:55:19 +02:00
f2fs: fix to do sanity check in update_sit_entry
[ Upstream commit 36959d18c3
]
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>
This commit is contained in:
parent
b9b019acfb
commit
428fb40bd9
|
@ -2398,6 +2398,8 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
segno = GET_SEGNO(sbi, blkaddr);
|
segno = GET_SEGNO(sbi, blkaddr);
|
||||||
|
if (segno == NULL_SEGNO)
|
||||||
|
return;
|
||||||
|
|
||||||
se = get_seg_entry(sbi, segno);
|
se = get_seg_entry(sbi, segno);
|
||||||
new_vblocks = se->valid_blocks + del;
|
new_vblocks = se->valid_blocks + del;
|
||||||
|
@ -3481,8 +3483,7 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
|
||||||
* since SSR needs latest valid block information.
|
* since SSR needs latest valid block information.
|
||||||
*/
|
*/
|
||||||
update_sit_entry(sbi, *new_blkaddr, 1);
|
update_sit_entry(sbi, *new_blkaddr, 1);
|
||||||
if (GET_SEGNO(sbi, old_blkaddr) != NULL_SEGNO)
|
update_sit_entry(sbi, old_blkaddr, -1);
|
||||||
update_sit_entry(sbi, old_blkaddr, -1);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the current segment is full, flush it out and replace it with a
|
* If the current segment is full, flush it out and replace it with a
|
||||||
|
|
Loading…
Reference in New Issue
Block a user