On 2019/3/14 äå4:03, Nikolay Borisov wrote:
Isn't assert() a bad idea for production build without assert() support?
On 14.03.19 Ð. 10:02 Ñ., Qu Wenruo wrote:
Then I'd rather have ASSERT(cache)
On 2019/3/14 äå3:54, Nikolay Borisov wrote:
Yep, that's the normal case.
On 14.03.19 Ð. 9:50 Ñ., Kangjie Lu wrote:
btrfs_lookup_block_group may fail and return NULL. The fix goesActually no, in this case btrfs_lookup_block_group must never fail
to out when it fails to avoid NULL pointer dereference.
because if we have an allocated eb then it must have been allocated from
a bg.
However I'm wondering if it's possible to get a bad eb which is cached.
Then we could hit such situation.
So I still believe being safe here still makes sense, especially who
knows future fuzzed image will be.
Thanks,
Qu
Thanks,
Qu
Signed-off-by: Kangjie Lu <kjlu@xxxxxxx>
---
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,