linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabian Frederick <fabf@skynet.be>
To: linux-kernel@vger.kernel.org
Cc: Fabian Frederick <fabf@skynet.be>, Chris Mason <clm@fb.com>,
	Josef Bacik <jbacik@fb.com>, David Sterba <dsterba@suse.cz>,
	linux-btrfs@vger.kernel.org
Subject: [PATCH 1/1] Btrfs: avoid using NULL compressed_pages in  insert_inline_extent()
Date: Sat, 25 Apr 2015 10:02:54 +0200	[thread overview]
Message-ID: <1429948974-24767-1-git-send-email-fabf@skynet.be> (raw)

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


                 reply	other threads:[~2015-04-25  8:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429948974-24767-1-git-send-email-fabf@skynet.be \
    --to=fabf@skynet.be \
    --cc=clm@fb.com \
    --cc=dsterba@suse.cz \
    --cc=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).