]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
imsm: Fix: klocwork: targets variable can be used uninitialized
authorAdam Kwolek <adam.kwolek@intel.com>
Tue, 14 Jun 2011 02:48:53 +0000 (12:48 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 14 Jun 2011 02:48:53 +0000 (12:48 +1000)
When target_offsets allocation fails execution goes to abort label,
where elements from targets table are closed.

Initialize targets table after allocation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
super-intel.c

index 7190f515d82ee4c8be0fd78c307948b8c44196c6..6c74e503c0d50abae30f4dba15cb94b219d199c2 100644 (file)
@@ -7716,13 +7716,15 @@ int save_backup_imsm(struct supertype *st,
        if (!targets)
                goto abort;
 
+       for (i = 0; i < new_disks; i++)
+               targets[i] = -1;
+
        target_offsets = malloc(new_disks * sizeof(unsigned long long));
        if (!target_offsets)
                goto abort;
 
        start = info->reshape_progress * 512;
        for (i = 0; i < new_disks; i++) {
-               targets[i] = -1;
                target_offsets[i] = (unsigned long long)
                  __le32_to_cpu(super->migr_rec->ckpt_area_pba) * 512;
                /* move back copy area adderss, it will be moved forward