]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
dm btree: fix leak of bufio-backed block in btree_split_sibling error path
authorMike Snitzer <snitzer@redhat.com>
Mon, 23 Nov 2015 21:24:45 +0000 (16:24 -0500)
committerMike Snitzer <snitzer@redhat.com>
Wed, 2 Dec 2015 18:20:34 +0000 (13:20 -0500)
The block allocated at the start of btree_split_sibling() is never
released if later insert_at() fails.

Fix this by releasing the previously allocated bufio block using
unlock_block().

Reported-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
drivers/md/persistent-data/dm-btree.c

index c573402033b2dd9e89dc11ad2f6e1b7e8bbb4263..0918a7c5f809766ea43faa0c5db96f1b22221325 100644 (file)
@@ -473,8 +473,10 @@ static int btree_split_sibling(struct shadow_spine *s, unsigned parent_index,
 
        r = insert_at(sizeof(__le64), pn, parent_index + 1,
                      le64_to_cpu(rn->keys[0]), &location);
-       if (r)
+       if (r) {
+               unlock_block(s->info, right);
                return r;
+       }
 
        if (key < le64_to_cpu(rn->keys[0])) {
                unlock_block(s->info, right);