From acc23d01ee7f8a6ccac81eb889f9f67283900320 Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Tue, 27 Aug 2013 14:18:54 -0700
Subject: [PATCH] Avoid possible invalid memory reference

---
 .../lustre/acct_gather_filesystem_lustre.c                   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/plugins/acct_gather_filesystem/lustre/acct_gather_filesystem_lustre.c b/src/plugins/acct_gather_filesystem/lustre/acct_gather_filesystem_lustre.c
index be61227724c..0e942d69d05 100644
--- a/src/plugins/acct_gather_filesystem/lustre/acct_gather_filesystem_lustre.c
+++ b/src/plugins/acct_gather_filesystem/lustre/acct_gather_filesystem_lustre.c
@@ -127,7 +127,7 @@ const char proc_base_path[] = "/proc/fs/lustre/";
 /**
  *  is lustre fs supported
  **/
-static int _check_lustre_fs()
+static int _check_lustre_fs(void)
 {
 	static bool set = false;
 	static int rc = SLURM_SUCCESS;
@@ -147,8 +147,9 @@ static int _check_lustre_fs()
 				debug2("not able to read %s",
 					lustre_directory);
 				rc = SLURM_FAILURE;
+			} else {
+				closedir(proc_dir);
 			}
-			closedir(proc_dir);
 		} else
 			rc = SLURM_ERROR;
 	}
-- 
GitLab