lkml.org 
[lkml]   [2015]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] Btrfs: avoid using NULL compressed_pages in insert_inline_extent()
Date
insert_inline_extent() checked for compressed_pages to be NULL then
it accessed it under compress_type != BTRFS_COMPRESS_NONE.
This patch adds a BUG() when compress_size != 0, compress_type !=
BTRFS_COMPRESS_NONE and compressed_pages == 0.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
fs/btrfs/inode.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ada4d24..449653d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -150,8 +150,12 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
size_t cur_size = size;
unsigned long offset;

- if (compressed_size && compressed_pages)
- cur_size = compressed_size;
+ if (compressed_size) {
+ if (compressed_pages)
+ cur_size = compressed_size;
+ else if (compress_type != BTRFS_COMPRESS_NONE)
+ BUG();
+ }

inode_add_bytes(inode, size);

--
1.9.1


\
 
 \ /
  Last update: 2015-04-25 10:21    [W:0.068 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site