@@ -452,20 +452,43 @@ static void gs_rx_push(struct work_struct *work)
static void gs_read_complete(struct usb_ep *ep, struct usb_request *req)
{
- struct gs_port *port = ep->driver_data;
+ struct gs_port *port;
+ unsigned long flags;
+
+ spin_lock_irqsave(&serial_port_lock, flags);
+ port = ep->driver_data;
+
+ if (!port) {
+ spin_unlock_irqrestore(&serial_port_lock, flags);
+ return;
+ }
- /* Queue all received data until the tty layer is ready for it. */
spin_lock(&port->port_lock);
+ spin_unlock(&serial_port_lock);
+
+ /* Queue all received data until the tty layer is ready for it. */
list_add_tail(&req->list, &port->read_queue);
schedule_delayed_work(&port->push, 0);
- spin_unlock(&port->port_lock);
+ spin_unlock_irqrestore(&port->port_lock, flags);
}
static void gs_write_complete(struct usb_ep *ep, struct usb_request *req)
{
- struct gs_port *port = ep->driver_data;
+ struct gs_port *port;
+ unsigned long flags;
+
+ spin_lock_irqsave(&serial_port_lock, flags);
+ port = ep->driver_data;
+
+ if (!port) {
+ spin_unlock_irqrestore(&serial_port_lock, flags);
+ return;
+ }
spin_lock(&port->port_lock);
+ spin_unlock(&serial_port_lock);
list_add(&req->list, &port->write_pool);
port->write_started--;
@@ -486,7 +509,7 @@ static void gs_write_complete(struct usb_ep *ep, struct usb_request *req)
break;