freevxfs: set bp to NULL after dropping its reference in loop
PATCH 1/1 freevxfs: set bp to NULL after dropping its reference in loop
The function vxfs_bmap_indir calls brelse(bh) in the loop and tries to start the next iteration. However, if it happens to break the loop, brelse(bp) will be called again. Resulting in a potential double free bug. This patch assigns NULL to bh after dropping its reference in the loop body.
Signed-off-by Pan Bian <[email protected]>
--- fs/freevxfs/vxfs_bmap.c | 2 ++ 1 file changed, 2 insertions(+)
fs/freevxfs/vxfs_bmap.c +2 -0
@@ -150,6 +150,7 @@ vxfs_bmap_indir(struct inode *ip, long indir, int size, long block)if (block < off) {brelse (bp); + bp =NULL ;continue ; }
@@ -186,6 +187,7 @@ vxfs_bmap_indir(struct inode *ip, long indir, int size, long block)BUG (); }brelse (bp); + bp =NULL ; } fail:
Signature · 1 line
2.7.4