]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Manage: Manage_subdevs() fix file descriptor leak
authorJes Sorensen <Jes.Sorensen@redhat.com>
Mon, 7 Mar 2016 18:53:43 +0000 (13:53 -0500)
committerJes Sorensen <Jes.Sorensen@redhat.com>
Wed, 9 Mar 2016 16:35:34 +0000 (11:35 -0500)
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Manage.c

index a812ba05d33543488c45a697cdc72d3d06e09b0c..ab4ac09fbefc4c5dbd934cb094c7cefd04ce1d56 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -1508,9 +1508,10 @@ int Manage_subdevs(char *devname, int fd,
                } else {
                        struct stat stb;
                        tfd = dev_open(dv->devname, O_RDONLY);
-                       if (tfd >= 0)
+                       if (tfd >= 0) {
                                fstat(tfd, &stb);
-                       else {
+                               close(tfd);
+                       } else {
                                int open_err = errno;
                                if (stat(dv->devname, &stb) != 0) {
                                        pr_err("Cannot find %s: %s\n",