Skip to contentSkip to conversation

freevxfs: set bp to NULL after dropping its reference in loop

PATCH New Pan Bian 1 participant 1 message Nov 25, 2018

lore
Share & tools
lore

Pan Bian

author
#0 lore raw

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.

---
 fs/freevxfs/vxfs_bmap.c | 2 ++
 1 file changed, 2 insertions(+)
fs/freevxfs/vxfs_bmap.c +2 -0
index 1fd41cf..136e5d1 100644
@@ -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