fs: affs: fix a NULL pointer dereference
Subsystems (2)
PATCH 1/1 fs: affs: fix a NULL pointer dereference
If affs_bread fails, do not use ext_bh to avoid NULL pointer
dereference
Signed-off-by Kangjie Lu <[email protected]>
--- fs/affs/file.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/affs/file.c +4 -2
@@ -941,8 +941,10 @@ affs_truncate(struct inode *inode) size =AFFS_SB (sb)->s_hashsize;if (size > blkcnt - blk) size = blkcnt - blk; -for (i =0 ; i < size; i++, blk++) -affs_free_block (sb,be32_to_cpu (AFFS_BLOCK (sb, ext_bh, i))); +if (ext_bh) { +for (i =0 ; i < size; i++, blk++) +affs_free_block (sb,be32_to_cpu (AFFS_BLOCK (sb, ext_bh, i))); + }affs_free_block (sb, ext_key); ext_key =be32_to_cpu (AFFS_TAIL (sb, ext_bh)->extension);affs_brelse (ext_bh);
Signature · 1 line
2.17.1
Quoted 4 lines · Kangjie Lu
If
affs_breadfails, do not useext_bhto avoid NULL pointer
dereferenceSigned-off-by Kangjie Lu <[email protected]>
Tanks for the patch. I'll need some more time to get familiar with the AFFS code to review your patch.