/* protection_trees_destroy - destroy the protection RB-trees. @ubi: UBI device description object  */
static void protection_trees_destroy(struct ubi_device *ubi)
/* protection_trees_destroy - destroy the protection RB-trees. @ubi: UBI device description object  */
static void protection_trees_destroy(struct ubi_device *ubi)
{
	struct rb_node *rb;
	struct ubi_wl_prot_entry *pe;
	rb = ubi->prot.aec.rb_node;
	while (rb) {
		if (rb->rb_left)
			rb = rb->rb_left;
		else if (rb->rb_right)
			rb = rb->rb_right;
		else {
			pe = rb_entry(rb, struct ubi_wl_prot_entry, rb_aec);
			rb = rb_parent(rb);
			if (rb) {
				if (rb->rb_left == &pe->rb_aec)
					rb->rb_left = NULL;
				else
					rb->rb_right = NULL;
			}
			kmem_cache_free(ubi_wl_entry_slab, pe->e);
			kfree(pe);
		}
	}
}