md/raid0: If md_integrity_register() fails, raid0_run() must free the mem.
authormajianpeng <majianpeng@gmail.com>
Sun, 1 Apr 2012 23:48:37 +0000 (09:48 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 1 Apr 2012 23:48:37 +0000 (09:48 +1000)
Signed-off-by: majianpeng <majianpeng@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/raid0.c

index 6f31f5596e01e0d032f50db71077e07d3af5c3e4..c9809453a346404df2e64c305df243585a2dc970 100644 (file)
@@ -407,6 +407,8 @@ static sector_t raid0_size(struct mddev *mddev, sector_t sectors, int raid_disks
        return array_sectors;
 }
 
+static int raid0_stop(struct mddev *mddev);
+
 static int raid0_run(struct mddev *mddev)
 {
        struct r0conf *conf;
@@ -454,7 +456,12 @@ static int raid0_run(struct mddev *mddev)
 
        blk_queue_merge_bvec(mddev->queue, raid0_mergeable_bvec);
        dump_zones(mddev);
-       return md_integrity_register(mddev);
+
+       ret = md_integrity_register(mddev);
+       if (ret)
+               raid0_stop(mddev);
+
+       return ret;
 }
 
 static int raid0_stop(struct mddev *mddev)