]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Grow.c
Grow: fix possible memory leak.
[thirdparty/mdadm.git] / Grow.c
diff --git a/Grow.c b/Grow.c
index e362403aa81e0e46c26273d9ae26dde1ad1d54f5..b73ec2aebb9f257548b3ebe2aacb5d3d3e080351 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -432,6 +432,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
                        if (((disk.state & (1 << MD_DISK_WRITEMOSTLY)) == 0) &&
                           (strcmp(s->bitmap_file, "clustered") == 0)) {
                                pr_err("%s disks marked write-mostly are not supported with clustered bitmap\n",devname);
+                               free(mdi);
                                return 1;
                        }
                        fd2 = dev_open(dv, O_RDWR);
@@ -453,8 +454,10 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
                                pr_err("failed to load super-block.\n");
                        }
                        close(fd2);
-                       if (rv)
+                       if (rv) {
+                               free(mdi);
                                return 1;
+                       }
                }
                if (offset_setable) {
                        st->ss->getinfo_super(st, mdi, NULL);