From f37d5e2439038ca05e34a0636396f9584c0e9f1e Mon Sep 17 00:00:00 2001 From: Jarkko Sakkinen Date: Tue, 28 Jan 2014 08:30:39 +0200 Subject: [PATCH] libsmack: close smackfs_mnt_dirfd in the library destructor Close smackfs_mnt_dirfd in the library destructor. Although kernel would wipe it anyway it is a good practice to clean up all the reserved resources. Signed-off-by: Jarkko Sakkinen --- libsmack/init.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libsmack/init.c b/libsmack/init.c index 9fb45e5..1d14086 100644 --- a/libsmack/init.c +++ b/libsmack/init.c @@ -154,12 +154,6 @@ out: return; } -void fini_smackmnt(void) -{ - free(smackfs_mnt); - smackfs_mnt = NULL; -} - static void init_lib(void) __attribute__ ((constructor)); static void init_lib(void) { @@ -169,5 +163,8 @@ static void init_lib(void) static void fini_lib(void) __attribute__ ((destructor)); static void fini_lib(void) { - fini_smackmnt(); + if (smackfs_mnt_dirfd >= 0) + close(smackfs_mnt_dirfd); + free(smackfs_mnt); + smackfs_mnt = NULL; } -- 2.7.4