]> Pileus Git - ~andy/linux/blobdiff - drivers/char/specialix.c
USB CDC NCM: tx_fixup() race condition fix
[~andy/linux] / drivers / char / specialix.c
index 2c24fcdc722a920fe00861be3b77fe76f168d2e6..c2bca3f25ef3f96f13c036ab2ae8c2a4976c7b27 100644 (file)
@@ -87,7 +87,6 @@
 #include <linux/tty_flip.h>
 #include <linux/mm.h>
 #include <linux/serial.h>
-#include <linux/smp_lock.h>
 #include <linux/fcntl.h>
 #include <linux/major.h>
 #include <linux/delay.h>
@@ -1365,7 +1364,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
                        retval = -ERESTARTSYS;
                        break;
                }
+               tty_unlock();
                schedule();
+               tty_lock();
        }
 
        set_current_state(TASK_RUNNING);
@@ -1863,8 +1864,7 @@ static int sx_set_serial_info(struct specialix_port *port,
                return -EFAULT;
        }
 
-       lock_kernel();
-
+       mutex_lock(&port->port.mutex);
        change_speed = ((port->port.flags & ASYNC_SPD_MASK) !=
                        (tmp.flags & ASYNC_SPD_MASK));
        change_speed |= (tmp.custom_divisor != port->custom_divisor);
@@ -1875,7 +1875,7 @@ static int sx_set_serial_info(struct specialix_port *port,
                    ((tmp.flags & ~ASYNC_USR_MASK) !=
                     (port->port.flags & ~ASYNC_USR_MASK))) {
                        func_exit();
-                       unlock_kernel();
+                       mutex_unlock(&port->port.mutex);
                        return -EPERM;
                }
                port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
@@ -1892,7 +1892,7 @@ static int sx_set_serial_info(struct specialix_port *port,
                sx_change_speed(bp, port);
 
        func_exit();
-       unlock_kernel();
+       mutex_unlock(&port->port.mutex);
        return 0;
 }
 
@@ -1906,7 +1906,7 @@ static int sx_get_serial_info(struct specialix_port *port,
        func_enter();
 
        memset(&tmp, 0, sizeof(tmp));
-       lock_kernel();
+       mutex_lock(&port->port.mutex);
        tmp.type = PORT_CIRRUS;
        tmp.line = port - sx_port;
        tmp.port = bp->base;
@@ -1917,7 +1917,7 @@ static int sx_get_serial_info(struct specialix_port *port,
        tmp.closing_wait = port->port.closing_wait * HZ/100;
        tmp.custom_divisor =  port->custom_divisor;
        tmp.xmit_fifo_size = CD186x_NFIFO;
-       unlock_kernel();
+       mutex_unlock(&port->port.mutex);
        if (copy_to_user(retinfo, &tmp, sizeof(tmp))) {
                func_exit();
                return -EFAULT;
@@ -2355,7 +2355,7 @@ static void __exit specialix_exit_module(void)
        func_exit();
 }
 
-static struct pci_device_id specialx_pci_tbl[] __devinitdata = {
+static struct pci_device_id specialx_pci_tbl[] __devinitdata __used = {
        { PCI_DEVICE(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_IO8) },
        { }
 };