From: Dan Carpenter <dan.carpenter@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [report] NULL dereference in __update_reloc_root()
Date: Fri, 22 Jun 2012 09:45:06 +0300 [thread overview]
Message-ID: <20120622064506.GA25515@elgon.mountain> (raw)
Hello Btrfs devs,
The patch 5d4f98a28c7d: "Btrfs: Mixed back reference (FORWARD
ROLLING FORMAT CHANGE)" from Jun 10, 2009, leads to the following
warning:
fs/btrfs/relocation.c:1270 __update_reloc_root()
error: potential NULL dereference 'node'.
fs/btrfs/relocation.c
1255 static int __update_reloc_root(struct btrfs_root *root, int del)
1256 {
1257 struct rb_node *rb_node;
1258 struct mapping_node *node = NULL;
1259 struct reloc_control *rc = root->fs_info->reloc_ctl;
1260
1261 spin_lock(&rc->reloc_root_tree.lock);
1262 rb_node = tree_search(&rc->reloc_root_tree.rb_root,
1263 root->commit_root->start);
1264 if (rb_node) {
1265 node = rb_entry(rb_node, struct mapping_node, rb_node);
^^^^^^^^^^^^^^^^
Node is only non-NULL if "rb_node" is non-NULL.
1266 rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root);
1267 }
1268 spin_unlock(&rc->reloc_root_tree.lock);
1269
1270 BUG_ON((struct btrfs_root *)node->data != root);
^^^^^^^^^^
Null dereference.
1271
1272 if (!del) {
1273 spin_lock(&rc->reloc_root_tree.lock);
1274 node->bytenr = root->node->start;
^^^^^^^^^^^^
We assume "node" is non-NULL on this side of the if else statement.
1275 rb_node = tree_insert(&rc->reloc_root_tree.rb_root,
1276 node->bytenr, &node->rb_node);
1277 spin_unlock(&rc->reloc_root_tree.lock);
1278 if (rb_node)
1279 backref_tree_panic(rb_node, -EEXIST, node->bytenr);
1280 } else {
1281 spin_lock(&root->fs_info->trans_lock);
1282 list_del_init(&root->root_list);
1283 spin_unlock(&root->fs_info->trans_lock);
1284 kfree(node);
^^^^^^^^^^^
And here as well I guess.
1285 }
1286 return 0;
regards,
dan carpenter
reply other threads:[~2012-06-22 6:45 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=20120622064506.GA25515@elgon.mountain \
--to=dan.carpenter@oracle.com \
--cc=linux-btrfs@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).