[PATCH] cscommon: Close MOK directory stream

Mikhail Dmitrichenko m.dmitrichenko222@gmail.com
Tue Jun 16 15:19:47 GMT 2026


mok_dir_valid_p() opens the MOK fingerprint directory only to verify
that it can be opened. The DIR stream is not used after the NULL check,
so successful calls leak the directory file descriptor on every return
path.

Close the directory stream immediately after the successful check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
---
 cscommon.cxx | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cscommon.cxx b/cscommon.cxx
index 958eebad3..98c73b30b 100644
--- a/cscommon.cxx
+++ b/cscommon.cxx
@@ -383,6 +383,7 @@ mok_dir_valid_p (const string &mok_fingerprint, const string &mok_path, bool ver
 			 mok_dir.c_str(), strerror(errno)), true);
       return false;
     }
+  closedir (dirp);
 
   // Find both the x509 certificate and private key files.
   string mok_private_cert_path = mok_dir + MOK_PRIVATE_CERT_FILE;
-- 
2.43.0



More information about the Systemtap mailing list