Manage: Manage_add(): Fix memory leak

sysfs_read() allocates and populates a struct mdinfo, however the code
forgot to free it again, before dropping the reference to the pointer.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
This commit is contained in:
Jes Sorensen 2016-03-07 11:51:24 -05:00
parent 31dbeda730
commit d209181d96
1 changed files with 3 additions and 0 deletions

View File

@ -944,10 +944,13 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
}
if (strncmp(mdp->sysfs_array_state, "readonly", 8) != 0) {
sysfs_free(mdp);
pr_err("%s is not readonly, cannot add journal.\n", devname);
return -1;
}
sysfs_free(mdp);
tst->ss->getinfo_super(tst, &mdi, NULL);
if (mdi.journal_device_required == 0) {
pr_err("%s does not support journal device.\n", devname);