From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Jia-Ju Bai <baijiaju1990@gmail.com>,
clm@fb.com, josef@toxicpanda.com, dsterba@suse.cz
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: btrfs: Add an assertion to warn incorrct case in insert_inline_extent()
Date: Sat, 27 Jul 2019 17:07:31 +0800 [thread overview]
Message-ID: <de8c1056-8b6b-42e2-561a-954f77b7ef6b@gmx.com> (raw)
In-Reply-To: <20190727085113.11530-1-baijiaju1990@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1064 bytes --]
On 2019/7/27 下午4:51, Jia-Ju Bai wrote:
> In insert_inline_extent(), the case that compressed_size > 0
> and compressed_pages = NULL cannot occur, otherwise a null-pointer
> dereference may occur on line 215:
> cpage = compressed_pages[i];
>
> To warn this incorrect case, an assertion is added.
> Thank Qu Wenruo and David Sterba for good advice.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/inode.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 1af069a9a0c7..21d6e2dcc25f 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -178,6 +178,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;
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-07-27 9:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-27 8:51 Jia-Ju Bai
2019-07-27 9:07 ` Qu Wenruo [this message]
2019-07-30 16:33 ` David Sterba
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=de8c1056-8b6b-42e2-561a-954f77b7ef6b@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=baijiaju1990@gmail.com \
--cc=clm@fb.com \
--cc=dsterba@suse.cz \
--cc=josef@toxicpanda.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
all inboxes | Powered by JetHome®