linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix a NULL pointer dereference
@ 2019-03-14  7:50 Kangjie Lu
  2019-03-14  7:54 ` Nikolay Borisov
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Kangjie Lu @ 2019-03-14  7:50 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	linux-kernel

btrfs_lookup_block_group may fail and return NULL. The fix goes
to out when it fails to avoid NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 fs/btrfs/extent-tree.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 994f0cc41799..b1e7985bcb9d 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7303,6 +7303,8 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
 
 		pin = 0;
 		cache = btrfs_lookup_block_group(fs_info, buf->start);
+		if (!cache)
+			goto out;
 
 		if (btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) {
 			pin_down_extent(fs_info, cache, buf->start,
-- 
2.17.1


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

end of thread, other threads:[~2019-03-25 16:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-14  7:50 [PATCH] btrfs: fix a NULL pointer dereference Kangjie Lu
2019-03-14  7:54 ` Nikolay Borisov
2019-03-14  8:02   ` Qu Wenruo
2019-03-14  8:03     ` Nikolay Borisov
2019-03-14  8:13       ` [PATCH v2] " Kangjie Lu
2019-03-14  8:16         ` Nikolay Borisov
2019-03-14  9:15       ` [PATCH] " Qu Wenruo
2019-03-14  9:18         ` Nikolay Borisov
2019-03-14 15:26         ` Kangjie Lu
2019-03-14 10:23     ` Su Yue
2019-03-14 15:41   ` Josef Bacik
2019-03-14  7:59 ` Qu Wenruo
2019-03-25 16:35 ` David Sterba

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).