From: Dan Carpenter <dan.carpenter@oracle.com>
To: wqu@suse.com
Cc: linux-btrfs@vger.kernel.org
Subject: [bug report] btrfs: locking: Add extra check in btrfs_init_new_buffer() to avoid deadlock
Date: Thu, 21 Feb 2019 17:13:47 +0300 [thread overview]
Message-ID: <20190221141347.GA20330@kadam> (raw)
[ This one is not actually your fault. It's the core code which is
confusing. -dan ]
Hello Qu Wenruo,
The patch b72c3aba09a5: "btrfs: locking: Add extra check in
btrfs_init_new_buffer() to avoid deadlock" from Aug 21, 2018, leads
to the following static checker warning:
fs/btrfs/extent-tree.c:8556 btrfs_init_new_buffer()
warn: possible NULL dereference of 'buf'
fs/btrfs/extent-tree.c
8540 static struct extent_buffer *
8541 btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root,
8542 u64 bytenr, int level, u64 owner)
8543 {
8544 struct btrfs_fs_info *fs_info = root->fs_info;
8545 struct extent_buffer *buf;
8546
8547 buf = btrfs_find_create_tree_block(fs_info, bytenr);
The btrfs_find_create_tree_block() function either returns
alloc_test_extent_buffer() which returns NULL on error or
alloc_extent_buffer() which returns error pointers on error. It
confuses static checkers and me also.
8548 if (IS_ERR(buf))
8549 return buf;
8550
8551 /*
8552 * Extra safety check in case the extent tree is corrupted and extent
8553 * allocator chooses to use a tree block which is already used and
8554 * locked.
8555 */
--> 8556 if (buf->lock_owner == current->pid) {
8557 btrfs_err_rl(fs_info,
8558 "tree block %llu owner %llu already locked by pid=%d, extent tree corruption detected",
8559 buf->start, btrfs_header_owner(buf), current->pid);
8560 free_extent_buffer(buf);
regards,
dan carpenter
next reply other threads:[~2019-02-21 14:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 14:13 Dan Carpenter [this message]
2019-02-21 14:21 ` [bug report] btrfs: locking: Add extra check in btrfs_init_new_buffer() to avoid deadlock Qu Wenruo
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=20190221141347.GA20330@kadam \
--to=dan.carpenter@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/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).