]> git.hungrycats.org Git - linux/commitdiff
Btrfs: fix panic in balance due to EIO
authorLiu Bo <bo.li.liu@oracle.com>
Tue, 12 Jul 2016 17:29:37 +0000 (10:29 -0700)
committerZygo Blaxell <zblaxell@waya.furryterror.org>
Wed, 17 Aug 2016 02:23:44 +0000 (22:23 -0400)
During build_backref_tree(), if we fail to read a btree node,
we can eventually run into BUG_ON(cache->nr_nodes) that we put
in backref_cache_cleanup(), meaning we have at least one
memory leak.

This frees the backref_node that we's allocated at the very
beginning of build_backref_tree().

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
(cherry picked from commit 0fd8c3dae14fb64947842472940b807ca0781da9)

fs/btrfs/relocation.c

index 08ef890deca69fdce7a35d26bcf5ae45d9f67d8b..13ae0c322135ea4f96f2fbc31db7eb872694536e 100644 (file)
@@ -1171,8 +1171,12 @@ out:
                        lower = list_entry(useless.next,
                                           struct backref_node, list);
                        list_del_init(&lower->list);
+                       if (lower == node)
+                               node = NULL;
                        free_backref_node(cache, lower);
                }
+
+               free_backref_node(cache, node);
                return ERR_PTR(err);
        }
        ASSERT(!node || !node->detached);