Commit fa2d8bbb authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Greg Kroah-Hartman

Staging: serqt_usb2: fix sleeping with spinlock held

The patch replaces spinlock with mutex.

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent eb93ca4e
...@@ -190,7 +190,7 @@ struct quatech_port { ...@@ -190,7 +190,7 @@ struct quatech_port {
struct usb_serial_port *port; /* owner of this object */ struct usb_serial_port *port; /* owner of this object */
struct qt_get_device_data DeviceData; struct qt_get_device_data DeviceData;
spinlock_t lock; struct mutex lock;
bool read_urb_busy; bool read_urb_busy;
int RxHolding; int RxHolding;
int ReadBulkStopped; int ReadBulkStopped;
...@@ -745,7 +745,7 @@ static int qt_startup(struct usb_serial *serial) ...@@ -745,7 +745,7 @@ static int qt_startup(struct usb_serial *serial)
} }
return -ENOMEM; return -ENOMEM;
} }
spin_lock_init(&qt_port->lock); mutex_init(&qt_port->lock);
usb_set_serial_port_data(port, qt_port); usb_set_serial_port_data(port, qt_port);
...@@ -1160,7 +1160,6 @@ static int qt_write_room(struct tty_struct *tty) ...@@ -1160,7 +1160,6 @@ static int qt_write_room(struct tty_struct *tty)
struct usb_serial_port *port = tty->driver_data; struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial; struct usb_serial *serial;
struct quatech_port *qt_port; struct quatech_port *qt_port;
unsigned long flags;
int retval = -EINVAL; int retval = -EINVAL;
...@@ -1176,7 +1175,7 @@ static int qt_write_room(struct tty_struct *tty) ...@@ -1176,7 +1175,7 @@ static int qt_write_room(struct tty_struct *tty)
qt_port = qt_get_port_private(port); qt_port = qt_get_port_private(port);
spin_lock_irqsave(&qt_port->lock, flags); mutex_lock(&qt_port->lock);
dbg("%s - port %d\n", __func__, port->number); dbg("%s - port %d\n", __func__, port->number);
...@@ -1185,7 +1184,7 @@ static int qt_write_room(struct tty_struct *tty) ...@@ -1185,7 +1184,7 @@ static int qt_write_room(struct tty_struct *tty)
retval = port->bulk_out_size; retval = port->bulk_out_size;
} }
spin_unlock_irqrestore(&qt_port->lock, flags); mutex_unlock(&qt_port->lock);
return retval; return retval;
} }
...@@ -1358,7 +1357,6 @@ static void qt_break(struct tty_struct *tty, int break_state) ...@@ -1358,7 +1357,6 @@ static void qt_break(struct tty_struct *tty, int break_state)
struct quatech_port *qt_port; struct quatech_port *qt_port;
u16 index, onoff; u16 index, onoff;
unsigned int result; unsigned int result;
unsigned long flags;
index = tty->index - serial->minor; index = tty->index - serial->minor;
...@@ -1369,7 +1367,7 @@ static void qt_break(struct tty_struct *tty, int break_state) ...@@ -1369,7 +1367,7 @@ static void qt_break(struct tty_struct *tty, int break_state)
else else
onoff = 0; onoff = 0;
spin_lock_irqsave(&qt_port->lock, flags); mutex_lock(&qt_port->lock);
dbg("%s - port %d\n", __func__, port->number); dbg("%s - port %d\n", __func__, port->number);
...@@ -1377,7 +1375,7 @@ static void qt_break(struct tty_struct *tty, int break_state) ...@@ -1377,7 +1375,7 @@ static void qt_break(struct tty_struct *tty, int break_state)
usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
QT_BREAK_CONTROL, 0x40, onoff, index, NULL, 0, 300); QT_BREAK_CONTROL, 0x40, onoff, index, NULL, 0, 300);
spin_unlock_irqrestore(&qt_port->lock, flags); mutex_unlock(&qt_port->lock);
} }
static inline int qt_real_tiocmget(struct tty_struct *tty, static inline int qt_real_tiocmget(struct tty_struct *tty,
...@@ -1466,21 +1464,20 @@ static int qt_tiocmget(struct tty_struct *tty) ...@@ -1466,21 +1464,20 @@ static int qt_tiocmget(struct tty_struct *tty)
struct usb_serial *serial = get_usb_serial(port, __func__); struct usb_serial *serial = get_usb_serial(port, __func__);
struct quatech_port *qt_port = qt_get_port_private(port); struct quatech_port *qt_port = qt_get_port_private(port);
int retval = -ENODEV; int retval = -ENODEV;
unsigned long flags;
dbg("In %s\n", __func__); dbg("In %s\n", __func__);
if (!serial) if (!serial)
return -ENODEV; return -ENODEV;
spin_lock_irqsave(&qt_port->lock, flags); mutex_lock(&qt_port->lock);
dbg("%s - port %d\n", __func__, port->number); dbg("%s - port %d\n", __func__, port->number);
dbg("%s - port->RxHolding = %d\n", __func__, qt_port->RxHolding); dbg("%s - port->RxHolding = %d\n", __func__, qt_port->RxHolding);
retval = qt_real_tiocmget(tty, port, serial); retval = qt_real_tiocmget(tty, port, serial);
spin_unlock_irqrestore(&qt_port->lock, flags); mutex_unlock(&qt_port->lock);
return retval; return retval;
} }
...@@ -1491,7 +1488,6 @@ static int qt_tiocmset(struct tty_struct *tty, ...@@ -1491,7 +1488,6 @@ static int qt_tiocmset(struct tty_struct *tty,
struct usb_serial_port *port = tty->driver_data; struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__); struct usb_serial *serial = get_usb_serial(port, __func__);
struct quatech_port *qt_port = qt_get_port_private(port); struct quatech_port *qt_port = qt_get_port_private(port);
unsigned long flags;
int retval = -ENODEV; int retval = -ENODEV;
dbg("In %s\n", __func__); dbg("In %s\n", __func__);
...@@ -1499,14 +1495,14 @@ static int qt_tiocmset(struct tty_struct *tty, ...@@ -1499,14 +1495,14 @@ static int qt_tiocmset(struct tty_struct *tty,
if (!serial) if (!serial)
return -ENODEV; return -ENODEV;
spin_lock_irqsave(&qt_port->lock, flags); mutex_lock(&qt_port->lock);
dbg("%s - port %d\n", __func__, port->number); dbg("%s - port %d\n", __func__, port->number);
dbg("%s - qt_port->RxHolding = %d\n", __func__, qt_port->RxHolding); dbg("%s - qt_port->RxHolding = %d\n", __func__, qt_port->RxHolding);
retval = qt_real_tiocmset(tty, port, serial, set); retval = qt_real_tiocmset(tty, port, serial, set);
spin_unlock_irqrestore(&qt_port->lock, flags); mutex_unlock(&qt_port->lock);
return retval; return retval;
} }
...@@ -1515,7 +1511,6 @@ static void qt_throttle(struct tty_struct *tty) ...@@ -1515,7 +1511,6 @@ static void qt_throttle(struct tty_struct *tty)
struct usb_serial_port *port = tty->driver_data; struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__); struct usb_serial *serial = get_usb_serial(port, __func__);
struct quatech_port *qt_port; struct quatech_port *qt_port;
unsigned long flags;
dbg("%s - port %d\n", __func__, port->number); dbg("%s - port %d\n", __func__, port->number);
...@@ -1524,13 +1519,13 @@ static void qt_throttle(struct tty_struct *tty) ...@@ -1524,13 +1519,13 @@ static void qt_throttle(struct tty_struct *tty)
qt_port = qt_get_port_private(port); qt_port = qt_get_port_private(port);
spin_lock_irqsave(&qt_port->lock, flags); mutex_lock(&qt_port->lock);
/* pass on to the driver specific version of this function */ /* pass on to the driver specific version of this function */
qt_port->RxHolding = 1; qt_port->RxHolding = 1;
dbg("%s - port->RxHolding = 1\n", __func__); dbg("%s - port->RxHolding = 1\n", __func__);
spin_unlock_irqrestore(&qt_port->lock, flags); mutex_unlock(&qt_port->lock);
return; return;
} }
...@@ -1539,7 +1534,6 @@ static void qt_unthrottle(struct tty_struct *tty) ...@@ -1539,7 +1534,6 @@ static void qt_unthrottle(struct tty_struct *tty)
struct usb_serial_port *port = tty->driver_data; struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__); struct usb_serial *serial = get_usb_serial(port, __func__);
struct quatech_port *qt_port; struct quatech_port *qt_port;
unsigned long flags;
unsigned int result; unsigned int result;
if (!serial) if (!serial)
...@@ -1547,7 +1541,7 @@ static void qt_unthrottle(struct tty_struct *tty) ...@@ -1547,7 +1541,7 @@ static void qt_unthrottle(struct tty_struct *tty)
qt_port = qt_get_port_private(port); qt_port = qt_get_port_private(port);
spin_lock_irqsave(&qt_port->lock, flags); mutex_lock(&qt_port->lock);
dbg("%s - port %d\n", __func__, port->number); dbg("%s - port %d\n", __func__, port->number);
...@@ -1573,7 +1567,7 @@ static void qt_unthrottle(struct tty_struct *tty) ...@@ -1573,7 +1567,7 @@ static void qt_unthrottle(struct tty_struct *tty)
__func__, result); __func__, result);
} }
} }
spin_unlock_irqrestore(&qt_port->lock, flags); mutex_unlock(&qt_port->lock);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment