Manage_runstop(): Avoid memory leak

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
Jes Sorensen 2011-11-01 16:09:31 +01:00 committed by NeilBrown
parent b73e45ae6a
commit bccd8153fa
1 changed files with 13 additions and 9 deletions

View File

@ -183,6 +183,7 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
* quiet < 0 means we will try again if it fails. * quiet < 0 means we will try again if it fails.
*/ */
mdu_param_t param; /* unused */ mdu_param_t param; /* unused */
int rv = 0;
if (runstop == -1 && md_get_version(fd) < 9000) { if (runstop == -1 && md_get_version(fd) < 9000) {
if (ioctl(fd, STOP_MD, 0)) { if (ioctl(fd, STOP_MD, 0)) {
@ -261,7 +262,8 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
fprintf(stderr, Name fprintf(stderr, Name
": failed to stop array %s: %s\n", ": failed to stop array %s: %s\n",
devname, strerror(errno)); devname, strerror(errno));
return 1; rv = 1;
goto out;
} }
/* Give monitor a chance to act */ /* Give monitor a chance to act */
@ -273,7 +275,8 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
": failed to completely stop %s" ": failed to completely stop %s"
": Device is busy\n", ": Device is busy\n",
devname); devname);
return 1; rv = 1;
goto out;
} }
} else if (mdi && } else if (mdi &&
mdi->array.major_version == -1 && mdi->array.major_version == -1 &&
@ -301,9 +304,8 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
"member %s still active\n", "member %s still active\n",
devname, m->dev); devname, m->dev);
free_mdstat(mds); free_mdstat(mds);
if (mdi) rv = 1;
sysfs_free(mdi); goto out;
return 1;
} }
} }
@ -328,9 +330,8 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
"process, mounted filesystem " "process, mounted filesystem "
"or active volume group?\n"); "or active volume group?\n");
} }
if (mdi) rv = 1;
sysfs_free(mdi); goto out;
return 1;
} }
/* prior to 2.6.28, KOBJ_CHANGE was not sent when an md array /* prior to 2.6.28, KOBJ_CHANGE was not sent when an md array
* was stopped, so We'll do it here just to be sure. Drop any * was stopped, so We'll do it here just to be sure. Drop any
@ -355,8 +356,11 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
map_lock(&map); map_lock(&map);
map_remove(&map, devnum); map_remove(&map, devnum);
map_unlock(&map); map_unlock(&map);
out:
if (mdi)
sysfs_free(mdi);
} }
return 0; return rv;
} }
int Manage_resize(char *devname, int fd, long long size, int raid_disks) int Manage_resize(char *devname, int fd, long long size, int raid_disks)