All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] freevxfs: set bp to NULL after dropping its reference in loop
@ 2018-11-25  1:49 Pan Bian
  0 siblings, 0 replies; only message in thread
From: Pan Bian @ 2018-11-25  1:49 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-kernel, Pan Bian

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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-11-25  1:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-25  1:49 [PATCH] freevxfs: set bp to NULL after dropping its reference in loop Pan Bian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.