diff options
author | Jia-Ju Bai <baijiaju1990@gmail.com> | 2019-07-27 16:51:13 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-09-09 14:59:00 +0200 |
commit | 982f1f5d161735efb85f85cd9c5fb4d61ccfc0aa (patch) | |
tree | fb7202089bf9ba6632af4841027bd87aa31f60fe /fs/btrfs/inode.c | |
parent | 330a582790452a159686c5dab8f4286babd9c00e (diff) | |
download | lwn-982f1f5d161735efb85f85cd9c5fb4d61ccfc0aa.tar.gz lwn-982f1f5d161735efb85f85cd9c5fb4d61ccfc0aa.zip |
btrfs: Add an assertion to warn incorrect case in insert_inline_extent()
In insert_inline_extent(), the case that checks compressed_size > 0
and compressed_pages = NULL cannot occur, otherwise a null-pointer
dereference may occur on line 215:
cpage = compressed_pages[i];
To catch this incorrect case, an assertion is added.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index c3feb5310e17..20963b6567ae 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -176,6 +176,9 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans, size_t cur_size = size; unsigned long offset; + ASSERT((compressed_size > 0 && compressed_pages) || + (compressed_size == 0 && !compressed_pages)); + if (compressed_size && compressed_pages) cur_size = compressed_size; |