linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] btrfs-progs: extent_io: Fix NULL pointer dereference in free_extent_buffer_final()
@ 2018-03-30  5:35 Qu Wenruo
  2018-03-30  5:35 ` [PATCH 2/5] btrfs-progs: extent_io: Init eb->lru to avoid NULL pointer dereference Qu Wenruo
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Qu Wenruo @ 2018-03-30  5:35 UTC (permalink / raw)
  To: linux-btrfs

In free_extent_buffer_final() we access eb->tree->cache_size in
BUG_ON().
However eb->tree can be NULL if it's a cloned extent buffer.

Currently the cloned extent buffer is only used in backref.c,
paths_from_inode() function.
Thankfully that function is not used yet (but could be pretty useful to
convert inode number to path, so I'd like to keep such function).

Anyway, check eb->tree before accessing its member.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 extent_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/extent_io.c b/extent_io.c
index eda1fb6f5897..986ad5c0577c 100644
--- a/extent_io.c
+++ b/extent_io.c
@@ -587,7 +587,7 @@ static void free_extent_buffer_final(struct extent_buffer *eb)
 	struct extent_io_tree *tree = eb->tree;
 
 	BUG_ON(eb->refs);
-	BUG_ON(tree->cache_size < eb->len);
+	BUG_ON(tree && tree->cache_size < eb->len);
 	list_del_init(&eb->lru);
 	if (!(eb->flags & EXTENT_BUFFER_DUMMY)) {
 		remove_cache_extent(&tree->cache, &eb->cache_node);
-- 
2.16.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-30  5:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-30  5:35 [PATCH 1/5] btrfs-progs: extent_io: Fix NULL pointer dereference in free_extent_buffer_final() Qu Wenruo
2018-03-30  5:35 ` [PATCH 2/5] btrfs-progs: extent_io: Init eb->lru to avoid NULL pointer dereference Qu Wenruo
2018-03-30  5:35 ` [PATCH 3/5] btrfs-progs: extent_io: Refactor alloc_extent_buffer() to follow kernel parameters Qu Wenruo
2018-03-30  5:35 ` [PATCH 4/5] btrfs-progs: Unify btrfs_leaf_free_psace() parameter with kernel Qu Wenruo
2018-03-30  5:35 ` [PATCH 5/5] btrfs-progs: print-tree: Remove btrfs_root parameter Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).