dm cache: fix error return code in cache_create
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Fri, 10 May 2013 13:37:14 +0000 (14:37 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Fri, 10 May 2013 13:37:14 +0000 (14:37 +0100)
Return -ENOMEM if memory allocation fails in cache_create
instead of 0 (to avoid NULL pointer dereference).

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Cc: stable@vger.kernel.org
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm-cache-target.c

index 10744091e6cabb5f6bb55e59709eb4ba0350a98b..6feaba24fcac800e72cb50ad87df4a26a37bc4bd 100644 (file)
@@ -1971,6 +1971,7 @@ static int cache_create(struct cache_args *ca, struct cache **result)
        atomic_set(&cache->nr_migrations, 0);
        init_waitqueue_head(&cache->migration_wait);
 
+       r = -ENOMEM;
        cache->nr_dirty = 0;
        cache->dirty_bitset = alloc_bitset(from_cblock(cache->cache_size));
        if (!cache->dirty_bitset) {