LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RFC 1/1 linux-next] Btrfs: avoid using NULL compressed_pages in  insert_inline_extent()
@ 2015-03-30 20:28 Fabian Frederick
  0 siblings, 0 replies; only message in thread
From: Fabian Frederick @ 2015-03-30 20:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: Fabian Frederick, Chris Mason, Josef Bacik, David Sterba, linux-btrfs

insert_inline_extent() checked for compressed_pages to be NULL then
it accessed it under compress_type != BTRFS_COMPRESS_NONE.
This patch adds BUG() when compress_size != 0, compress_type !=
BTRFS_COMPRESS_NONE and compresses_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 686331f..95e0c29 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -149,8 +149,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


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

only message in thread, other threads:[~2015-03-30 20:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-30 20:28 [RFC 1/1 linux-next] Btrfs: avoid using NULL compressed_pages in insert_inline_extent() Fabian Frederick

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