From: Jes Sorensen Date: Wed, 2 Nov 2011 21:08:23 +0000 (+1100) Subject: close_aa(): Verify file descriptors are valid before trying to close them X-Git-Tag: mdadm-3.2.3~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c20478757de9b2746860365a3d644c441fb87f97;p=thirdparty%2Fmdadm.git close_aa(): Verify file descriptors are valid before trying to close them Signed-off-by: Jes Sorensen Signed-off-by: NeilBrown --- diff --git a/managemon.c b/managemon.c index fceaeb9c..cde0d8be 100644 --- a/managemon.c +++ b/managemon.c @@ -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)