lkml.org 
[lkml]   [2018]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] freevxfs: set bp to NULL after dropping its reference in loop
Date
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 <bianpan2016@163.com>
---
fs/freevxfs/vxfs_bmap.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/fs/freevxfs/vxfs_bmap.c b/fs/freevxfs/vxfs_bmap.c
index 1fd41cf..136e5d1 100644
--- a/fs/freevxfs/vxfs_bmap.c
+++ b/fs/freevxfs/vxfs_bmap.c
@@ -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:
--
2.7.4

\
 
 \ /
  Last update: 2018-11-25 02:50    [W:0.029 / U:0.700 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site