[rtems commit] IMFS: Fix resource leak

Sebastian Huber sebh at rtems.org
Thu Feb 12 20:48:07 UTC 2015


Module:    rtems
Branch:    master
Commit:    11026956c6ae3039c8a358a02fcd4ca6fac65e8f
Changeset: http://git.rtems.org/rtems/commit/?id=11026956c6ae3039c8a358a02fcd4ca6fac65e8f

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Feb  6 20:50:49 2015 +0100

IMFS: Fix resource leak

---

 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;
 }
 




More information about the vc mailing list