goto bad_digest_len;
}
- bht->root_digest = (u8 *) kzalloc(bht->digest_size, GFP_KERNEL);
- if (!bht->root_digest) {
- DMERR("failed to allocate memory for root digest");
- status = -ENOMEM;
- goto bad_root_digest_alloc;
- }
-
/* Configure the tree */
bht->block_count = block_count;
DMDEBUG("Setting block_count %u", block_count);
bad_node_count:
bad_level_alloc:
bad_block_count:
- kfree(bht->root_digest);
-bad_root_digest_alloc:
bad_digest_len:
for (cpu = 0; cpu < nr_cpu_ids; ++cpu)
if (bht->hash_desc[cpu].tfm)
unsigned int depth;
int cpu = 0;
- kfree(bht->root_digest);
-
depth = bht->depth;
while (depth-- != 0) {
struct dm_bht_entry *entry = bht->levels[depth].entries;
*/
int dm_bht_set_root_hexdigest(struct dm_bht *bht, const u8 *hexdigest)
{
- if (!bht->root_digest) {
- DMCRIT("No allocation for root digest. Call dm_bht_create");
- return -1;
- }
/* Make sure we have at least the bytes expected */
if (strnlen((char *)hexdigest, bht->digest_size * 2) !=
bht->digest_size * 2) {
DMERR("hexdigest has too few bytes available");
return -EINVAL;
}
- if (!bht->root_digest) {
- DMERR("no root digest exists to export");
- if (available > 0)
- *hexdigest = 0;
- return -1;
- }
dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size);
return 0;
}
sector_t sectors; /* Number of disk sectors used */
/* bool verified; Full tree is verified */
- u8 *root_digest; /* hash_alg(levels[0].entries[*].nodes) */
+ u8 root_digest[DM_BHT_MAX_DIGEST_SIZE];
struct dm_bht_level *levels; /* in reverse order */
mempool_t *entry_pool;
/* Callbacks for reading and/or writing to the hash device */