bcache: fix use-after-free in btree_gc_coalesce()
authorSlava Pestov <sp@daterainc.com>
Sun, 13 Jul 2014 04:53:11 +0000 (21:53 -0700)
committerKent Overstreet <kmo@daterainc.com>
Mon, 4 Aug 2014 22:23:04 +0000 (15:23 -0700)
If we goto out_nocoalesce after we free new_nodes[0], we end up freeing
new_nodes[0] again. This was generating a lockdep warning. The fix is
to set new_nodes[0] to NULL, since the out_nocoalesce path safely
ignores NULL entries in the new_nodes array.

This regression was introduced in 2d7f9531.

Change-Id: I76564d7257800583214376b4bacf236cda90c89c

drivers/md/bcache/btree.c

index f8237856a61ba36e47917f0f743d1ce1b47dac43..776583f7247db449cbf05b8835ebc521185d810f 100644 (file)
@@ -1409,6 +1409,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
        BUG_ON(btree_bset_first(new_nodes[0])->keys);
        btree_node_free(new_nodes[0]);
        rw_unlock(true, new_nodes[0]);
+       new_nodes[0] = NULL;
 
        for (i = 0; i < nodes; i++) {
                if (__bch_keylist_realloc(&keylist, bkey_u64s(&r[i].b->key)))
This page took 0.025153 seconds and 5 git commands to generate.