diff options
-rw-r--r-- | cpukit/ChangeLog | 4 | ||||
-rw-r--r-- | cpukit/score/src/corerwlockrelease.c | 49 |
2 files changed, 29 insertions, 24 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index a1b3e8d538..70c47843d8 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,7 @@ +2007-05-22 Joel Sherrill <joel.sherrill@OARcorp.com> + + * score/src/corerwlockrelease.c: Do not dereference NULL. + 2007-05-21 Joel Sherrill <joel.sherrill@oarcorp.com> * rtems/Makefile.am, rtems/include/rtems/rtems/barrier.h, diff --git a/cpukit/score/src/corerwlockrelease.c b/cpukit/score/src/corerwlockrelease.c index 30daaeaba9..b9d0e2f9e1 100644 --- a/cpukit/score/src/corerwlockrelease.c +++ b/cpukit/score/src/corerwlockrelease.c @@ -79,32 +79,33 @@ CORE_RWLock_Status _CORE_RWLock_Release( next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue ); - rwmode = next->Wait.option; - if ( rwmode == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) { - the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING; - return CORE_RWLOCK_SUCCESSFUL; - } - - /* - * Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING now see if more - * readers can be let go. - */ - - while ( 1 ) { - next = _Thread_queue_First( &the_rwlock->Wait_queue ); - if ( !next ) - return CORE_RWLOCK_SUCCESSFUL; - if ( next->Wait.option != CORE_RWLOCK_THREAD_WAITING_FOR_READ ) - return CORE_RWLOCK_SUCCESSFUL; - - /* it is definitely wanting to read */ - the_rwlock->number_of_readers += 1; - _Thread_queue_Extract( &the_rwlock->Wait_queue, next ); - } - - + if ( next ) { + rwmode = next->Wait.option; + if ( rwmode == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) { + the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING; + return CORE_RWLOCK_SUCCESSFUL; + } + + /* + * Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING now see if more + * readers can be let go. + */ + + while ( 1 ) { + next = _Thread_queue_First( &the_rwlock->Wait_queue ); + if ( !next ) + return CORE_RWLOCK_SUCCESSFUL; + if ( next->Wait.option != CORE_RWLOCK_THREAD_WAITING_FOR_READ ) + return CORE_RWLOCK_SUCCESSFUL; + + /* it is definitely wanting to read */ + the_rwlock->number_of_readers += 1; + _Thread_queue_Extract( &the_rwlock->Wait_queue, next ); + } /* XXX need to put read/write lock request indicator in Wait info */ + } + return CORE_RWLOCK_SUCCESSFUL; } |