CHROMIUM: verity: add BUG in check_block for consistency with verify_path

We assume that the caller guarantees that all nodes along the path are
already populated. We already have a BUG_ON checking this in verify_path.
This change adds a similar BUG_ON in check_path and removes the code
which checks the entry state.

TBR=wad(code already LGTMed and submitted to kernel.git)
BUG=9752
TEST=Ran unit tests in dm-verity.git. Ran platform_DMVerityCorruption on H/W.

Change-Id: Id456d9e495978c93d0be28bd895e5ced28d9973b
Signed-off-by: Mandeep Singh Baines <msb@chromium.org>

kernel.git Review URL: http://codereview.chromium.org/6246094

Review URL: http://codereview.chromium.org/6632013
diff --git a/dm-bht.c b/dm-bht.c
index 4ac06fa..35713de 100644
--- a/dm-bht.c
+++ b/dm-bht.c
@@ -606,17 +606,10 @@
 	index = block_index >> bht->node_count_shift;
 	entry = &bht->levels[depth].entries[index];
 
-	*entry_state = atomic_read(&entry->state);
-	if (*entry_state <= DM_BHT_ENTRY_ERROR) {
-		DMCRIT("leaf entry for block %u is invalid",
-		       block_index);
-		return *entry_state;
-	}
-	if (*entry_state <= DM_BHT_ENTRY_PENDING) {
-		DMERR("leaf data not yet loaded for block %u",
-		      block_index);
-		return 1;
-	}
+	/* This call is only safe if all nodes along the path
+	 * are already populated (i.e. READY) via dm_bht_populate.
+	 */
+	BUG_ON(atomic_read(&entry->state) < DM_BHT_ENTRY_READY);
 
 	/* Index into the entry data */
 	index = (block_index % bht->node_count) * bht->digest_size;