ChangeSet 1.1043.1.11, 2003/02/17 10:09:00-08:00, baldrick@wanadoo.fr

[PATCH] USB speedtouch: fix speedtouch micro race

The disconnect routine counts the completed_receivers/spare_senders list
to see if the completion handler has finished.  It then kills the tasklet.
However the tasklet was being scheduled after adding to the lists, creating
a micro race.  So schedule the tasklet before adding to the list.


diff -Nru a/drivers/usb/misc/speedtouch.c b/drivers/usb/misc/speedtouch.c
--- a/drivers/usb/misc/speedtouch.c	Tue Feb 18 16:40:50 2003
+++ b/drivers/usb/misc/speedtouch.c	Tue Feb 18 16:40:50 2003
@@ -334,12 +334,11 @@
 		return;
 	}
 
+	tasklet_schedule (&instance->receive_tasklet);
 	/* may not be in_interrupt() */
 	spin_lock_irqsave (&instance->completed_receivers_lock, flags);
 	list_add_tail (&rcv->list, &instance->completed_receivers);
 	spin_unlock_irqrestore (&instance->completed_receivers_lock, flags);
-	PDEBUG ("udsl_complete_receive: scheduling tasklet\n");
-	tasklet_schedule (&instance->receive_tasklet);
 }
 
 static void udsl_process_receive (unsigned long data)
@@ -497,13 +496,12 @@
 		return;
 	}
 
+	tasklet_schedule (&instance->send_tasklet);
 	/* may not be in_interrupt() */
 	spin_lock_irqsave (&instance->send_lock, flags);
 	list_add (&snd->list, &instance->spare_senders);
 	list_add (&snd->buffer->list, &instance->spare_buffers);
 	spin_unlock_irqrestore (&instance->send_lock, flags);
-	PDEBUG ("udsl_complete_send: scheduling tasklet\n");
-	tasklet_schedule (&instance->send_tasklet);
 }
 
 static void udsl_process_send (unsigned long data)
