From 17f0fd39d8b1f8edb420721c38302bd46254db03 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 21 Jan 2013 09:43:30 -0700 Subject: [PATCH] axmap: clear map->first_free when we reset it Otherwise it could be left at an invalid value. When we clear the map, we know the first free bit is 0. Signed-off-by: Jens Axboe --- lib/axmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/axmap.c b/lib/axmap.c index a44e0ecb..d9ad30bf 100644 --- a/lib/axmap.c +++ b/lib/axmap.c @@ -67,6 +67,8 @@ void axmap_reset(struct axmap *axmap) memset(al->map, 0, al->map_size * sizeof(unsigned long)); } + + axmap->first_free = 0; } void axmap_free(struct axmap *axmap) @@ -101,7 +103,6 @@ struct axmap *axmap_new(unsigned long nr_bits) axmap->nr_levels = levels; axmap->levels = smalloc(axmap->nr_levels * sizeof(struct axmap_level)); - axmap->first_free = 0; for (i = 0; i < axmap->nr_levels; i++) { struct axmap_level *al = &axmap->levels[i]; -- 2.25.1