]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Manage: Manage_add(): Fix memory leak
authorJes Sorensen <Jes.Sorensen@redhat.com>
Mon, 7 Mar 2016 16:51:24 +0000 (11:51 -0500)
committerJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 22 Mar 2016 18:03:12 +0000 (14:03 -0400)
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>
Manage.c

index e3d46f3b968ec28bc2cfef44e026a624f5ca7084..530826038a99652d10999f8a35daca573481d2a3 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -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);