[PATCH 5/7] IMFS: Fix resource leak

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Feb 9 20:35:55 UTC 2015


---
 cpukit/libfs/src/imfs/imfs_link.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/cpukit/libfs/src/imfs/imfs_link.c b/cpukit/libfs/src/imfs/imfs_link.c
index 27e04ff..06794af 100644
--- a/cpukit/libfs/src/imfs/imfs_link.c
+++ b/cpukit/libfs/src/imfs/imfs_link.c
@@ -119,7 +119,7 @@ static IMFS_jnode_t *IMFS_node_remove_hard_link(
 
   _Assert( target != NULL );
 
-  if ( target->st_nlink == 1) {
+  if ( target->st_nlink == 1 ) {
     target = (*target->control->node_remove)( target );
     if ( target == NULL ) {
       node = NULL;
@@ -129,6 +129,14 @@ static IMFS_jnode_t *IMFS_node_remove_hard_link(
     IMFS_update_ctime( target );
   }
 
+  if ( target != NULL ) {
+    --target->reference_count;
+
+    if ( target->reference_count == 0 ) {
+      IMFS_node_destroy( target );
+    }
+  }
+
   return node;
 }
 
-- 
2.1.4




More information about the devel mailing list