Under some special conditions (too big chunk size or zero-sized device), the resulting hash_size is calculated as zero. rounddown_pow_of_two(0) is undefined operation (it expands to shift by -1). And init_exception_table with zero argument would fail with -ENOMEM. This patch makes minimum chunk size 64, just like for pending exception table. Signed-off-by: Mikulas Patocka --- drivers/md/dm-snap.c | 2 ++ 1 file changed, 2 insertions(+) Index: linux-2.6.31-fast-new-2/drivers/md/dm-snap.c =================================================================== --- linux-2.6.31-fast-new-2.orig/drivers/md/dm-snap.c 2009-10-16 20:54:34.000000000 +0200 +++ linux-2.6.31-fast-new-2/drivers/md/dm-snap.c 2009-10-16 21:47:47.000000000 +0200 @@ -569,6 +569,8 @@ static int init_hash_tables(struct dm_sn hash_size = min(origin_dev_size, cow_dev_size) >> s->store->chunk_shift; hash_size = min(hash_size, max_buckets); + if (hash_size < 64) + hash_size = 64; hash_size = rounddown_pow_of_two(hash_size); if (dm_exception_table_init(&s->complete, hash_size, DM_CHUNK_CONSECUTIVE_BITS))