/* This function destroys the volume RB-tree (@sv->root) and the scanning volume information.  */
static void destroy_sv(struct ubi_scan_volume *sv)
/* This function destroys the volume RB-tree (@sv->root) and the scanning volume information.  */
static void destroy_sv(struct ubi_scan_volume *sv)
{
	struct ubi_scan_leb *seb;
	struct rb_node *this = sv->root.rb_node;
	while (this) {
		if (this->rb_left)
			this = this->rb_left;
		else if (this->rb_right)
			this = this->rb_right;
		else {
			seb = rb_entry(this, struct ubi_scan_leb, u.rb);
			this = rb_parent(this);
			if (this) {
				if (this->rb_left == &seb->u.rb)
					this->rb_left = NULL;
				else
					this->rb_right = NULL;
			}
			kfree(seb);
		}
	}
	kfree(sv);
}