patch-2.4.9 linux/drivers/parport/share.c

Next file: linux/drivers/pci/pci.c
Previous file: linux/drivers/parport/parport_pc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.8/linux/drivers/parport/share.c linux/drivers/parport/share.c
@@ -782,6 +782,21 @@
 
 	spin_unlock(&port->pardevice_lock);
 
+	/* Make sure we haven't left any pointers around in the wait
+	 * list. */
+	spin_lock (&port->waitlist_lock);
+	if (dev->waitprev || dev->waitnext || port->waithead == dev) {
+		if (dev->waitprev)
+			dev->waitprev->waitnext = dev->waitnext;
+		else
+			port->waithead = dev->waitnext;
+		if (dev->waitnext)
+			dev->waitnext->waitprev = dev->waitprev;
+		else
+			port->waittail = dev->waitprev;
+	}
+	spin_unlock (&port->waitlist_lock);
+
 	kfree(dev->state);
 	kfree(dev);
 
@@ -1063,6 +1078,7 @@
 
 	/* If anybody is waiting, find out who's been there longest and
 	   then wake them up. (Note: no locking required) */
+	/* !!! LOCKING IS NEEDED HERE */
 	for (pd = port->waithead; pd; pd = pd->waitnext) {
 		if (pd->waiting & 2) { /* sleeping in claim_or_block */
 			parport_claim(pd);
@@ -1080,6 +1096,7 @@
 
 	/* Nobody was waiting, so walk the list to see if anyone is
 	   interested in being woken up. (Note: no locking required) */
+	/* !!! LOCKING IS NEEDED HERE */
 	for (pd = port->devices; (port->cad == NULL) && pd; pd = pd->next) {
 		if (pd->wakeup && pd != dev)
 			pd->wakeup(pd->private);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)