Index: cpukit/ChangeLog
===================================================================
--- cpukit/ChangeLog	(revision fcc69714b36623ec0adb4944132b3c28126c5e1b)
+++ cpukit/ChangeLog	(revision b3b8add4b425709c711ff1515754b09b755aad11)
@@ -1,2 +1,11 @@
+2010-02-16	Chris Johns <chrisj@rtems.org>
+
+	* libcsupport/src/open.c: Tighten the open handler check.
+
+2010-02-16	Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+	* libcsupport/src/rmdir.c, libcsupport/src/unlink.c: Free the
+	allocated pathloc.
+	
 2010-02-01	Chris Johns <chrisj@rtems.org>
 
Index: cpukit/libcsupport/src/open.c
===================================================================
--- cpukit/libcsupport/src/open.c	(revision fcc69714b36623ec0adb4944132b3c28126c5e1b)
+++ cpukit/libcsupport/src/open.c	(revision b3b8add4b425709c711ff1515754b09b755aad11)
@@ -159,5 +159,5 @@
   iop->pathinfo   = loc;
 
-  if ( !iop->handlers->open_h ) {
+  if ( !iop->handlers || !iop->handlers->open_h ) {
     rc = ENOTSUP;
     goto done;
Index: cpukit/libcsupport/src/rmdir.c
===================================================================
--- cpukit/libcsupport/src/rmdir.c	(revision fcc69714b36623ec0adb4944132b3c28126c5e1b)
+++ cpukit/libcsupport/src/rmdir.c	(revision b3b8add4b425709c711ff1515754b09b755aad11)
@@ -35,4 +35,5 @@
   int                               i;
   int                               result;
+  bool                              free_parentloc = false;
 
   /*
@@ -51,4 +52,6 @@
     if ( result != 0 )
       return -1;
+
+    free_parentloc = true;
   }
 
@@ -64,5 +67,6 @@
                                                     0, &loc, false );
   if ( result != 0 ) {
-    rtems_filesystem_freenode( &parentloc );
+    if ( free_parentloc )
+      rtems_filesystem_freenode( &parentloc );
     return -1;
   }
@@ -74,5 +78,6 @@
   if ( !loc.ops->node_type_h ){
     rtems_filesystem_freenode( &loc );
-    rtems_filesystem_freenode( &parentloc );
+    if ( free_parentloc )
+      rtems_filesystem_freenode( &parentloc );
     rtems_set_errno_and_return_minus_one( ENOTSUP );
   }
@@ -80,5 +85,6 @@
   if (  (*loc.ops->node_type_h)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ){
     rtems_filesystem_freenode( &loc );
-    rtems_filesystem_freenode( &parentloc );
+    if ( free_parentloc )
+      rtems_filesystem_freenode( &parentloc );
     rtems_set_errno_and_return_minus_one( ENOTDIR );
   }
@@ -90,5 +96,6 @@
   if ( !loc.handlers->rmnod_h ){
     rtems_filesystem_freenode( &loc );
-    rtems_filesystem_freenode( &parentloc );
+    if ( free_parentloc )
+      rtems_filesystem_freenode( &parentloc );
     rtems_set_errno_and_return_minus_one( ENOTSUP );
   }
@@ -97,5 +104,6 @@
 
   rtems_filesystem_freenode( &loc );
-  rtems_filesystem_freenode( &parentloc );
+  if ( free_parentloc )
+    rtems_filesystem_freenode( &parentloc );
 
   return result;
Index: cpukit/libcsupport/src/unlink.c
===================================================================
--- cpukit/libcsupport/src/unlink.c	(revision fcc69714b36623ec0adb4944132b3c28126c5e1b)
+++ cpukit/libcsupport/src/unlink.c	(revision b3b8add4b425709c711ff1515754b09b755aad11)
@@ -31,4 +31,5 @@
   int                               i;
   int                               result;
+  bool                              free_parentloc = false;
 
   /*
@@ -47,4 +48,6 @@
     if ( result != 0 )
       return -1;
+
+    free_parentloc = true;
   }
 
@@ -60,5 +63,6 @@
                                                     0, &loc, false );
   if ( result != 0 ) {
-    rtems_filesystem_freenode( &parentloc );
+    if ( free_parentloc )
+      rtems_filesystem_freenode( &parentloc );
     return -1;
   }
@@ -66,5 +70,6 @@
   if ( !loc.ops->node_type_h ) {
     rtems_filesystem_freenode( &loc );
-    rtems_filesystem_freenode( &parentloc );
+    if ( free_parentloc )
+      rtems_filesystem_freenode( &parentloc );
     rtems_set_errno_and_return_minus_one( ENOTSUP );
   }
@@ -72,5 +77,6 @@
   if (  (*loc.ops->node_type_h)( &loc ) == RTEMS_FILESYSTEM_DIRECTORY ) {
     rtems_filesystem_freenode( &loc );
-    rtems_filesystem_freenode( &parentloc );
+    if ( free_parentloc )
+      rtems_filesystem_freenode( &parentloc );
     rtems_set_errno_and_return_minus_one( EISDIR );
   }
@@ -78,5 +84,6 @@
   if ( !loc.ops->unlink_h ) {
     rtems_filesystem_freenode( &loc );
-    rtems_filesystem_freenode( &parentloc );
+    if ( free_parentloc )
+      rtems_filesystem_freenode( &parentloc );
     rtems_set_errno_and_return_minus_one( ENOTSUP );
   }
@@ -85,5 +92,6 @@
 
   rtems_filesystem_freenode( &loc );
-  rtems_filesystem_freenode( &parentloc );
+  if ( free_parentloc )
+    rtems_filesystem_freenode( &parentloc );
 
   return result;
