]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 19 May 2013 18:38:17 +0000 (11:38 -0700)
commit fa4d683af3693863bec761e2761a07e4c1351f86 upstream.

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>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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) {