summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-01-29 17:19:15 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-01-29 17:19:15 +0000
commit803b02fde09195ad4bfbee4e2d4212b76660aec4 (patch)
tree6abfe6f1ef849259b7090d2fd6f5681844e9ac3e
parentff90a778b865a69b1e856224d127a365e2d1bd18 (diff)
2009-01-29 Nickolay Semyonov-Kolchin <nbkolchin@gmail.com>
PR 1359/cpukit * libcsupport/src/libio.c: rtems_libio_allocate: rtems_libio_iop_freelist incorrectly zeroed on semaphore error. Now checks error and does not modify anything until sure it has created semaphore.
-rw-r--r--cpukit/ChangeLog8
-rw-r--r--cpukit/libcsupport/src/libio.c14
2 files changed, 16 insertions, 6 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index a7f96c50b0..3e2ce1500a 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,3 +1,11 @@
+2009-01-29 Nickolay Semyonov-Kolchin <nbkolchin@gmail.com>
+
+ PR 1359/cpukit
+ * libcsupport/src/libio.c: rtems_libio_allocate:
+ rtems_libio_iop_freelist incorrectly zeroed on semaphore error. Now
+ checks error and does not modify anything until sure it has created
+ semaphore.
+
2009-01-29 Gene Smith <gene.smith@siemens.com>
PR 1363/filesystem
diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c
index 0c42b61854..21ac8b5b0f 100644
--- a/cpukit/libcsupport/src/libio.c
+++ b/cpukit/libcsupport/src/libio.c
@@ -196,23 +196,25 @@ rtems_libio_t *rtems_libio_allocate( void )
{
rtems_libio_t *iop, *next;
rtems_status_code rc;
+ rtems_id sema;
rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
if (rtems_libio_iop_freelist) {
- iop = rtems_libio_iop_freelist;
- next = iop->data1;
- (void) memset( iop, 0, sizeof(rtems_libio_t) );
- iop->flags = LIBIO_FLAGS_OPEN;
rc = rtems_semaphore_create(
- RTEMS_LIBIO_IOP_SEM(iop - rtems_libio_iops),
+ RTEMS_LIBIO_IOP_SEM(rtems_libio_iop_freelist - rtems_libio_iops),
1,
RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
RTEMS_NO_PRIORITY,
- &iop->sem
+ &sema
);
if (rc != RTEMS_SUCCESSFUL)
goto failed;
+ iop = rtems_libio_iop_freelist;
+ next = iop->data1;
+ (void) memset( iop, 0, sizeof(rtems_libio_t) );
+ iop->flags = LIBIO_FLAGS_OPEN;
+ iop->sem = sema;
rtems_libio_iop_freelist = next;
goto done;
}