瀏覽代碼

dm btree: fix leak of bufio-backed block in btree_split_sibling error path

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
Mike Snitzer 9 年之前
父節點
當前提交
30ce6e1cc5
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      drivers/md/persistent-data/dm-btree.c

+ 3 - 1
drivers/md/persistent-data/dm-btree.c

@@ -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,
 	r = insert_at(sizeof(__le64), pn, parent_index + 1,
 		      le64_to_cpu(rn->keys[0]), &location);
 		      le64_to_cpu(rn->keys[0]), &location);
-	if (r)
+	if (r) {
+		unlock_block(s->info, right);
 		return r;
 		return r;
+	}
 
 
 	if (key < le64_to_cpu(rn->keys[0])) {
 	if (key < le64_to_cpu(rn->keys[0])) {
 		unlock_block(s->info, right);
 		unlock_block(s->info, right);