diff options
author | Adam Kwolek <adam.kwolek@intel.com> | 2011-03-18 12:32:16 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-03-18 12:32:16 +1100 |
commit | 983fff45a163e35f1a4d309b39ee9a0cbbc2195a (patch) | |
tree | 9117d15f814d49f4a0900864628f61e45e4f5c0d /Incremental.c | |
parent | d6221e667f55c46505125ae182051de499000ed8 (diff) |
FIX: ping_monitor() usage causes memory leaks
When for ping_monitor() input devnum2devname() is used,
received string pointer should be passed to free() for memory release.
It is not made in several places. This use case should have function
to avoid memory leak.
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Incremental.c')
-rw-r--r-- | Incremental.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Incremental.c b/Incremental.c index 300bdca7..72180607 100644 --- a/Incremental.c +++ b/Incremental.c @@ -438,7 +438,7 @@ int Incremental(char *devname, int verbose, int runstop, /* 7/ Is there enough devices to possibly start the array? */ /* 7a/ if not, finish with success. */ if (info.array.level == LEVEL_CONTAINER) { - char *devname = NULL; + int devnum; /* Try to assemble within the container */ map_unlock(&map); sysfs_uevent(&info, "change"); @@ -448,7 +448,7 @@ int Incremental(char *devname, int verbose, int runstop, chosen_name, info.array.working_disks); wait_for(chosen_name, mdfd); if (st->ss->external) - devname = devnum2devname(fd2devnum(mdfd)); + devnum = fd2devnum(mdfd); close(mdfd); sysfs_free(sra); rv = Incremental(chosen_name, verbose, runstop, @@ -460,10 +460,8 @@ int Incremental(char *devname, int verbose, int runstop, rv = 0; /* after spare is added, ping monitor for external metadata * so that it can eg. try to rebuild degraded array */ - if (st->ss->external) { - ping_monitor(devname); - free(devname); - } + if (st->ss->external) + ping_monitor_by_id(devnum); return rv; } |