Changeset d891cba in mainline


Ignore:
Timestamp:
2012-08-17T11:03:10Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ffc1b1d
Parents:
f9bd2e3
Message:

Phones in IPC cleanup need to be accessed under the protection of their
mutex as the other side may be tampering with them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ipc.c

    rf9bd2e3 rd891cba  
    626626restart:
    627627        /*
    628          * Go through all phones, until they are all FREE. Locking is not
    629          * needed, no one else should modify it when we are in cleanup
     628         * Go through all phones, until they are all free.
     629         * Locking is needed as there may be connection handshakes in progress.
    630630         */
    631631        for (i = 0; i < IPC_MAX_PHONES; i++) {
    632                 if (TASK->phones[i].state == IPC_PHONE_HUNGUP &&
    633                     atomic_get(&TASK->phones[i].active_calls) == 0) {
    634                         TASK->phones[i].state = IPC_PHONE_FREE;
    635                         TASK->phones[i].callee = NULL;
     632                phone_t *phone = &TASK->phones[i];
     633
     634                mutex_lock(&phone->lock);       
     635                if ((phone->state == IPC_PHONE_HUNGUP) &&
     636                    (atomic_get(&phone->active_calls) == 0)) {
     637                        phone->state = IPC_PHONE_FREE;
     638                        phone->callee = NULL;
    636639                }
    637640
     
    645648                 * phone.
    646649                 */
    647                 if ((TASK->phones[i].state == IPC_PHONE_CONNECTED) ||
    648                     (TASK->phones[i].state == IPC_PHONE_SLAMMED)) {
    649                         ipc_phone_hangup(&TASK->phones[i]);
     650                if ((phone->state == IPC_PHONE_CONNECTED) ||
     651                    (phone->state == IPC_PHONE_SLAMMED)) {
     652                        mutex_unlock(&phone->lock);
     653                        ipc_phone_hangup(phone);
    650654                        /*
    651655                         * Now there may be one extra active call, which needs
     
    660664                 * IPC is now in HUNGUP state, we wait for the reply to come
    661665                 */
    662                 if (TASK->phones[i].state != IPC_PHONE_FREE)
     666                if (phone->state != IPC_PHONE_FREE) {
     667                        mutex_unlock(&phone->lock);
    663668                        break;
     669                }
     670
     671                mutex_unlock(&phone->lock);
    664672        }
    665673               
     
    671679            SYNCH_FLAGS_NONE);
    672680        ASSERT(call->flags & (IPC_CALL_ANSWERED | IPC_CALL_NOTIF));
    673                
    674681        ipc_call_free(call);
    675682        goto restart;
Note: See TracChangeset for help on using the changeset viewer.