aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/io_edgeport.c
diff options
context:
space:
mode:
authorOliver Neukum <oneukum@suse.de>2007-03-15 10:27:17 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-04-27 16:28:36 -0400
commit96c706ed1c46470598d785124b2a7fb233b27dab (patch)
treee83913e0ad362043b67e163751f8a1abb0c64199 /drivers/usb/serial/io_edgeport.c
parente198a31489146bb723fef179e5d1d18c8225f246 (diff)
USB: io_edgeport race condition in counters
io_edgeport is using a global variable without locking. This is _the_ classical race condition. This patch switches to atomic_t. Signed-off-by: Oliver Neukum <oneukum@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/io_edgeport.c')
-rw-r--r--drivers/usb/serial/io_edgeport.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 6a26a2e683a6..187fd4280c88 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -212,7 +212,7 @@ static int debug;
212 212
213static int low_latency = 1; /* tty low latency flag, on by default */ 213static int low_latency = 1; /* tty low latency flag, on by default */
214 214
215static int CmdUrbs = 0; /* Number of outstanding Command Write Urbs */ 215static atomic_t CmdUrbs; /* Number of outstanding Command Write Urbs */
216 216
217 217
218/* local function prototypes */ 218/* local function prototypes */
@@ -779,8 +779,8 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
779 779
780 dbg("%s", __FUNCTION__); 780 dbg("%s", __FUNCTION__);
781 781
782 CmdUrbs--; 782 atomic_dec(&CmdUrbs);
783 dbg("%s - FREE URB %p (outstanding %d)", __FUNCTION__, urb, CmdUrbs); 783 dbg("%s - FREE URB %p (outstanding %d)", __FUNCTION__, urb, atomic_read(&CmdUrbs));
784 784
785 785
786 /* clean up the transfer buffer */ 786 /* clean up the transfer buffer */
@@ -2317,8 +2317,8 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer
2317 if (!urb) 2317 if (!urb)
2318 return -ENOMEM; 2318 return -ENOMEM;
2319 2319
2320 CmdUrbs++; 2320 atomic_inc(&CmdUrbs);
2321 dbg("%s - ALLOCATE URB %p (outstanding %d)", __FUNCTION__, urb, CmdUrbs); 2321 dbg("%s - ALLOCATE URB %p (outstanding %d)", __FUNCTION__, urb, atomic_read(&CmdUrbs));
2322 2322
2323 usb_fill_bulk_urb (urb, edge_serial->serial->dev, 2323 usb_fill_bulk_urb (urb, edge_serial->serial->dev,
2324 usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint), 2324 usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint),
@@ -2332,7 +2332,7 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer
2332 dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write command) failed, status = %d\n", __FUNCTION__, status); 2332 dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write command) failed, status = %d\n", __FUNCTION__, status);
2333 usb_kill_urb(urb); 2333 usb_kill_urb(urb);
2334 usb_free_urb(urb); 2334 usb_free_urb(urb);
2335 CmdUrbs--; 2335 atomic_dec(&CmdUrbs);
2336 return status; 2336 return status;
2337 } 2337 }
2338 2338
@@ -3083,6 +3083,7 @@ static int __init edgeport_init(void)
3083 retval = usb_register(&io_driver); 3083 retval = usb_register(&io_driver);
3084 if (retval) 3084 if (retval)
3085 goto failed_usb_register; 3085 goto failed_usb_register;
3086 atomic_set(&CmdUrbs, 0);
3086 info(DRIVER_DESC " " DRIVER_VERSION); 3087 info(DRIVER_DESC " " DRIVER_VERSION);
3087 return 0; 3088 return 0;
3088 3089