浏览代码

firewire: fully initialize fw_transaction before marking it pending

In theory, card->flush_timer could already access a transaction between
fw_send_request()'s spin_unlock_irqrestore and the rest of what happens
in fw_send_request().  This would happen if the process which sends the
request is preempted and put to sleep right after spin_unlock_irqrestore
for longer than 100ms.

Therefore we fill in everything in struct fw_transaction at which the
flush_timer might look at before we lift the lock.

To do:  Ensure that the timer does not pick up the transaction before
the time of the AT request event plus split transaction timeout.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Stefan Richter 17 年之前
父节点
当前提交
e9aeb46c93
共有 1 个文件被更改,包括 4 次插入5 次删除
  1. 4 5
      drivers/firewire/fw-transaction.c

+ 4 - 5
drivers/firewire/fw-transaction.c

@@ -279,11 +279,6 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
 	card->current_tlabel = (card->current_tlabel + 1) & 0x1f;
 	card->current_tlabel = (card->current_tlabel + 1) & 0x1f;
 	card->tlabel_mask |= (1 << tlabel);
 	card->tlabel_mask |= (1 << tlabel);
 
 
-	list_add_tail(&t->link, &card->transaction_list);
-
-	spin_unlock_irqrestore(&card->lock, flags);
-
-	/* Initialize rest of transaction, fill out packet and send it. */
 	t->node_id = node_id;
 	t->node_id = node_id;
 	t->tlabel = tlabel;
 	t->tlabel = tlabel;
 	t->callback = callback;
 	t->callback = callback;
@@ -294,6 +289,10 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
 			speed, offset, payload, length);
 			speed, offset, payload, length);
 	t->packet.callback = transmit_complete_callback;
 	t->packet.callback = transmit_complete_callback;
 
 
+	list_add_tail(&t->link, &card->transaction_list);
+
+	spin_unlock_irqrestore(&card->lock, flags);
+
 	card->driver->send_request(card, &t->packet);
 	card->driver->send_request(card, &t->packet);
 }
 }
 EXPORT_SYMBOL(fw_send_request);
 EXPORT_SYMBOL(fw_send_request);