Fixed a race condition in the USB code.

This commit is contained in:
solomon 2002-05-23 14:39:05 +00:00
parent 34bec64a37
commit 98addc4495
2 changed files with 23 additions and 18 deletions

View file

@ -43,6 +43,7 @@
* --------------------------------------------------------------------
0.1.14
-pre4
- Fixed a race condition in the USB code.
- Applied Godmar Back's "SSIDs with spaces" patch.
-pre3
- Applied pizza's patch to remove the pb_t structure and make all

View file

@ -3610,48 +3610,52 @@ hfa384x_usbctlxq_run(
{
unsigned long flags;
int result;
hfa384x_usbctlx_t *head;
DBFENTER;
/* acquire lock */
spin_lock_irqsave(&ctlxq->lock, flags);
/* we need to split this off to avoid a race condition */
head = ctlxq->head;
/* Run the queue: If head in non-running state, submit urb, and
* set state to REQ_SUBMITTED.
*/
if (ctlxq->head != NULL &&
ctlxq->head->state == HFA384x_USBCTLX_QUEUED) {
result = usb_submit_urb(&ctlxq->head->outurb);
if (head != NULL &&
head->state == HFA384x_USBCTLX_QUEUED) {
result = usb_submit_urb(&head->outurb);
if (result) {
WLAN_LOG_ERROR1(__FUNCTION__
":Fatal, failed to submit command urb. error=%d\n",
result);
ctlxq->head->state = HFA384x_USBCTLX_REQSUBMIT_FAIL;
head->state = HFA384x_USBCTLX_REQSUBMIT_FAIL;
/* release lock */
spin_unlock_irqrestore(&ctlxq->lock, flags);
hfa384x_usbctlx_complete(ctlxq->head);
hfa384x_usbctlx_complete(head);
goto done;
}
ctlxq->head->state = HFA384x_USBCTLX_REQ_SUBMITTED;
head->state = HFA384x_USBCTLX_REQ_SUBMITTED;
/* Start the IN wait timer */
init_timer(&ctlxq->head->resptimer);
ctlxq->head->resptimer.function =
init_timer(&head->resptimer);
head->resptimer.function =
hfa384x_usbctlx_resptimerfn;
ctlxq->head->resptimer.data =
(unsigned long)ctlxq->head;
ctlxq->head->resptimer.expires = jiffies + 2*HZ;
add_timer(&ctlxq->head->resptimer);
head->resptimer.data =
(unsigned long)head;
head->resptimer.expires = jiffies + 2*HZ;
add_timer(&head->resptimer);
/* Start the OUT wait timer */
init_timer(&ctlxq->head->reqtimer);
ctlxq->head->reqtimer.function =
init_timer(&head->reqtimer);
head->reqtimer.function =
hfa384x_usbctlx_reqtimerfn;
ctlxq->head->reqtimer.data =
(unsigned long)ctlxq->head;
ctlxq->head->reqtimer.expires = jiffies + HZ;
add_timer(&ctlxq->head->reqtimer);
head->reqtimer.data =
(unsigned long)head;
head->reqtimer.expires = jiffies + HZ;
add_timer(&head->reqtimer);
}
/* release lock */