axmap: use calloc() for level alloc
authorJens Axboe <axboe@kernel.dk>
Sun, 8 Apr 2018 21:42:50 +0000 (15:42 -0600)
committerJens Axboe <axboe@kernel.dk>
Sun, 8 Apr 2018 21:42:50 +0000 (15:42 -0600)
We rely on it being set to NULL for error handling.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
lib/axmap.c

index bf203dfe7b2d0ba379ee09b06a6924c3bd00fd03..3c65308cde18e61c116a322fa0b2df6b740cfb16 100644 (file)
@@ -102,7 +102,7 @@ struct axmap *axmap_new(unsigned long nr_bits)
        }
 
        axmap->nr_levels = levels;
-       axmap->levels = malloc(axmap->nr_levels * sizeof(struct axmap_level));
+       axmap->levels = calloc(axmap->nr_levels, sizeof(struct axmap_level));
        axmap->nr_bits = nr_bits;
 
        for (i = 0; i < axmap->nr_levels; i++) {