libsmack: close smackfs_mnt_dirfd in the library destructor
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tue, 28 Jan 2014 06:30:39 +0000 (08:30 +0200)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tue, 28 Jan 2014 06:30:39 +0000 (08:30 +0200)
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 <jarkko.sakkinen@linux.intel.com>
libsmack/init.c

index 9fb45e5..1d14086 100644 (file)
@@ -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;
 }