md/bitmap: fix wrong cleanup
authorShaohua Li <shli@fb.com>
Tue, 13 Sep 2016 17:28:00 +0000 (10:28 -0700)
committerShaohua Li <shli@fb.com>
Wed, 21 Sep 2016 16:09:44 +0000 (09:09 -0700)
if bitmap_create fails, the bitmap is already cleaned up and the returned value
is an error number. We can't do the cleanup again.

Reported-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/bitmap.c

index 13041ee37ad6b504a4e1c1182a10cce9d77d0f9d..2d826927a3bf9bd1da8c8f6850fa29e320011908 100644 (file)
@@ -1903,10 +1903,8 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
        struct bitmap_counts *counts;
        struct bitmap *bitmap = bitmap_create(mddev, slot);
 
-       if (IS_ERR(bitmap)) {
-               bitmap_free(bitmap);
+       if (IS_ERR(bitmap))
                return PTR_ERR(bitmap);
-       }
 
        rv = bitmap_init_from_disk(bitmap, 0);
        if (rv)