Re: USB: FIx locks and urb->status in adutux

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Pete Zaitcev <zaitcev@...>
Cc: <linux-usb-devel@...>, <greg@...>, <linux-kernel@...>, <vitalivanov@...>, <netwiz@...>
Date: Wednesday, October 24, 2007 - 10:49 am

Am Mittwoch 24 Oktober 2007 schrieb Pete Zaitcev:

But you are leaving a function while still on a waitqueue left on the stack.
Here's a patch on top of yours.

	Regards
		Oliver

----

--- work/drivers/usb/misc/adutux.c.alt	2007-10-24 16:36:02.000000000 +0200
+++ work/drivers/usb/misc/adutux.c	2007-10-24 16:36:06.000000000 +0200
@@ -567,19 +567,21 @@ static ssize_t adu_write(struct file *fi
 
 	retval = mutex_lock_interruptible(&dev->mtx);
 	if (retval)
-		goto exit_nolock;
+		goto exit_nolock_intr;
 
 	/* verify that the device wasn't unplugged */
 	if (dev->udev == NULL) {
+		mutex_unlock(&dev->mtx);
 		retval = -ENODEV;
 		err("No device or device unplugged %d", retval);
-		goto exit;
+		goto exit_nolock_intr;
 	}
 
 	/* verify that we actually have some data to write */
 	if (count == 0) {
+		mutex_unlock(&dev->mtx);
 		dbg(1," %s : write request of 0 bytes", __FUNCTION__);
-		goto exit;
+		goto exit_nolock_intr;
 	}
 
 	add_wait_queue(&dev->write_wait, &waita);
@@ -649,13 +651,14 @@ static ssize_t adu_write(struct file *fi
 			bytes_written += bytes_to_write;
 		}
 	}
-	remove_wait_queue(&dev->write_wait, &waita);
 
 	retval = bytes_written;
 
 exit:
 	mutex_unlock(&dev->mtx);
 exit_nolock:
+	remove_wait_queue(&dev->write_wait, &waita);
+exit_nolock_intr:
 
 	dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
 
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
USB: FIx locks and urb-&gt;status in adutux, Pete Zaitcev, (Mon Oct 22, 11:34 pm)
Re: USB: FIx locks and urb-&gt;status in adutux, Pete Zaitcev, (Tue Oct 23, 9:53 pm)
Re: USB: FIx locks and urb->status in adutux, Oliver Neukum, (Wed Oct 24, 10:49 am)
Re: USB: FIx locks and urb-&gt;status in adutux, Greg KH, (Wed Oct 24, 5:25 pm)
Re: USB: FIx locks and urb-&gt;status in adutux, Vitaliy Ivanov, (Fri Oct 26, 5:57 am)
Re: USB: FIx locks and urb-&gt;status in adutux, Vitaliy Ivanov, (Wed Oct 24, 10:09 am)
Re: USB: FIx locks and urb-&gt;status in adutux, Pete Zaitcev, (Wed Oct 24, 11:25 pm)
Re: USB: FIx locks and urb-&gt;status in adutux, Vitaliy Ivanov, (Mon Oct 29, 2:04 pm)
Re: USB: FIx locks and urb-&gt;status in adutux, Pete Zaitcev, (Tue Oct 30, 12:24 am)
Re: USB: FIx locks and urb-&gt;status in adutux, Vitaliy Ivanov, (Tue Oct 30, 9:09 am)
Re: USB: FIx locks and urb-&gt;status in adutux, Pete Zaitcev, (Tue Oct 30, 5:54 pm)
Re: USB: FIx locks and urb-&gt;status in adutux, Vitaliy Ivanov, (Wed Oct 31, 7:54 am)
Re: USB: FIx locks and urb-&gt;status in adutux, Pete Zaitcev, (Wed Oct 31, 6:01 pm)
Re: USB: FIx locks and urb-&gt;status in adutux, Vitaliy Ivanov, (Thu Nov 1, 5:06 am)
Re: USB: FIx locks and urb-&gt;status in adutux, Pete Zaitcev, (Thu Nov 1, 1:28 pm)
Re: USB: FIx locks and urb-&gt;status in adutux, Pete Zaitcev, (Wed Oct 24, 11:20 pm)
Re: USB: FIx locks and urb-&gt;status in adutux, Pete Zaitcev, (Tue Oct 23, 5:38 pm)
Re: USB: FIx locks and urb-&gt;status in adutux, Oliver Neukum, (Wed Oct 24, 10:04 am)