aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2013-11-09 06:38:09 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-25 11:39:40 -0500
commit6f6485463aada1ec6a0f3db6a03eb8e393d6bb55 (patch)
tree762025100372064a9dd63223fc201d8e79fcebea /drivers/usb
parent6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff)
USB: serial: fix race in generic write
Fix race in generic write implementation, which could lead to temporarily degraded throughput. The current generic write implementation introduced by commit 27c7acf22047 ("USB: serial: reimplement generic fifo-based writes") has always had this bug, although it's fairly hard to trigger and the consequences are not likely to be noticed. Specifically, a write() on one CPU while the completion handler is running on another could result in only one of the two write urbs being utilised to empty the remainder of the write fifo (unless there is a second write() that doesn't race during that time). Cc: stable <stable@vger.kernel.org> # 2.6.35 Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/generic.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 2b01ec8651c2..e36b25a2fa02 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -173,16 +173,8 @@ retry:
173 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); 173 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags);
174 return result; 174 return result;
175 } 175 }
176 /*
177 * Try sending off another urb, unless called from completion handler
178 * (in which case there will be no free urb or no data).
179 */
180 if (mem_flags != GFP_ATOMIC)
181 goto retry;
182 176
183 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); 177 goto retry; /* try sending off another urb */
184
185 return 0;
186} 178}
187EXPORT_SYMBOL_GPL(usb_serial_generic_write_start); 179EXPORT_SYMBOL_GPL(usb_serial_generic_write_start);
188 180