]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Avoid double close()
authorJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 30 Jul 2013 16:30:03 +0000 (18:30 +0200)
committerNeilBrown <neilb@suse.de>
Tue, 30 Jul 2013 22:51:16 +0000 (08:51 +1000)
Coverity discovered a possible double close(fd2) in Grow.c. Avoided by
invalidating fd2 after the first close.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Grow.c

diff --git a/Grow.c b/Grow.c
index c1ae6e839312d31a8213fc12ea2e7dde35a5cc0d..ff4ed5dd9a95b752c2b0c040a3427c85e80f45d5 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -4685,6 +4685,8 @@ int Grow_continue_command(char *devname, int fd,
                                continue;
                        err = st->ss->load_super(st, fd2, NULL);
                        close(fd2);
+                       /* invalidate fd2 to avoid possible double close() */
+                       fd2 = -1;
                        if (err)
                                continue;
                        break;