diff options
Diffstat (limited to '')
-rw-r--r-- | cpukit/posix/src/semaphorecreatesupp.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/cpukit/posix/src/semaphorecreatesupp.c b/cpukit/posix/src/semaphorecreatesupp.c index 9a24e0a724..79db8888d8 100644 --- a/cpukit/posix/src/semaphorecreatesupp.c +++ b/cpukit/posix/src/semaphorecreatesupp.c @@ -54,11 +54,6 @@ int _POSIX_Semaphore_Create_support( if (pshared != 0) rtems_set_errno_and_return_minus_one( ENOSYS ); - the_semaphore = _POSIX_Semaphore_Allocate_unprotected(); - if ( !the_semaphore ) { - rtems_set_errno_and_return_minus_one( ENOSPC ); - } - /* * Make a copy of the user's string for name just in case it was * dynamically constructed. @@ -66,13 +61,18 @@ int _POSIX_Semaphore_Create_support( if ( name_arg != NULL ) { name = _Workspace_String_duplicate( name_arg, name_len ); if ( !name ) { - _POSIX_Semaphore_Free( the_semaphore ); rtems_set_errno_and_return_minus_one( ENOMEM ); } } else { name = NULL; } + the_semaphore = _POSIX_Semaphore_Allocate_unprotected(); + if ( !the_semaphore ) { + _Workspace_Free( name ); + rtems_set_errno_and_return_minus_one( ENOSPC ); + } + the_semaphore->process_shared = pshared; if ( name ) { |