# HG changeset patch # User Florian Pose # Date 1172825121 0 # Node ID 74ceacf4271098cf531b35e8acb7f29a4e523add # Parent 7f281d7372c667734afa71eaac6e3e2977e64bae Fixed possible race with next request pointer again. diff -r 7f281d7372c6 -r 74ceacf42710 master/fsm_master.c --- a/master/fsm_master.c Fri Mar 02 07:45:00 2007 +0000 +++ b/master/fsm_master.c Fri Mar 02 08:45:21 2007 +0000 @@ -284,11 +284,19 @@ ) { ec_master_t *master = fsm->master; - ec_eeprom_write_request_t *request, *next; + ec_eeprom_write_request_t *request; ec_slave_t *slave; - down(&master->eeprom_sem); - list_for_each_entry_safe(request, next, &master->eeprom_requests, list) { + // search the first request to be processed + while (1) { + down(&master->eeprom_sem); + if (list_empty(&master->eeprom_requests)) { + up(&master->eeprom_sem); + break; + } + // get first request + request = list_entry(master->eeprom_requests.next, + ec_eeprom_write_request_t, list); list_del_init(&request->list); // dequeue up(&master->eeprom_sem); @@ -298,7 +306,6 @@ slave->ring_position); request->state = EC_EEPROM_REQ_ERROR; wake_up_interruptible(&master->eeprom_queue); - down(&master->eeprom_sem); continue; } @@ -313,7 +320,6 @@ return 1; } - up(&master->eeprom_sem); return 0; }