]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
close_aa(): Verify file descriptors are valid before trying to close them
authorJes Sorensen <Jes.Sorensen@redhat.com>
Wed, 2 Nov 2011 21:08:23 +0000 (08:08 +1100)
committerNeilBrown <neilb@suse.de>
Wed, 2 Nov 2011 21:08:23 +0000 (08:08 +1100)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
managemon.c

index fceaeb9c41a073c9da884301b702ea30c1c3d2d7..cde0d8be9169092c4331837a7868ed9cb2a881be 100644 (file)
@@ -117,11 +117,16 @@ static void close_aa(struct active_array *aa)
                close(d->state_fd);
        }
 
-       close(aa->action_fd);
-       close(aa->info.state_fd);
-       close(aa->resync_start_fd);
-       close(aa->metadata_fd);
-       close(aa->sync_completed_fd);
+       if (aa->action_fd >= 0)
+               close(aa->action_fd);
+       if (aa->info.state_fd >= 0)
+               close(aa->info.state_fd);
+       if (aa->resync_start_fd >= 0)
+               close(aa->resync_start_fd);
+       if (aa->metadata_fd >= 0)
+               close(aa->metadata_fd);
+       if (aa->sync_completed_fd >= 0)
+               close(aa->sync_completed_fd);
 }
 
 static void free_aa(struct active_array *aa)