USB: serial: fix invalid user-pointer checks
authorJohan Hovold <johan@kernel.org>
Tue, 8 Nov 2016 12:26:50 +0000 (13:26 +0100)
committerJohan Hovold <johan@kernel.org>
Fri, 11 Nov 2016 16:54:04 +0000 (17:54 +0100)
Drop invalid user-pointer checks from ioctl handlers.

A NULL-pointer can be valid in user space and copy_to_user() takes care
of sanity checking.

Signed-off-by: Johan Hovold <johan@kernel.org>
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/io_edgeport.c
drivers/usb/serial/io_ti.c
drivers/usb/serial/mos7720.c
drivers/usb/serial/mos7840.c
drivers/usb/serial/opticon.c
drivers/usb/serial/quatech2.c
drivers/usb/serial/ssu100.c
drivers/usb/serial/ti_usb_3410_5052.c
drivers/usb/serial/usb_wwan.c

index b2d767e743fc2258c8b13e84401e5f34b60efcec..bf750e98d2044ab27847947ec3fa3db0f1773c09 100644 (file)
@@ -1452,8 +1452,6 @@ static int get_serial_info(struct usb_serial_port *port,
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        struct serial_struct tmp;
 
-       if (!retinfo)
-               return -EFAULT;
        memset(&tmp, 0, sizeof(tmp));
        tmp.flags = priv->flags;
        tmp.baud_base = priv->baud_base;
@@ -1535,9 +1533,6 @@ static int get_lsr_info(struct usb_serial_port *port,
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        unsigned int result = 0;
 
-       if (!retinfo)
-               return -EFAULT;
-
        if (priv->transmit_empty)
                result = TIOCSER_TEMT;
 
index 11c05ce2f35f8cd8ffe1ea46b0f6b0fed83e5064..dcc0c58aaad5adaf89bdd535d4cd9699445de3ac 100644 (file)
@@ -1554,9 +1554,6 @@ static int get_serial_info(struct edgeport_port *edge_port,
 {
        struct serial_struct tmp;
 
-       if (!retinfo)
-               return -EFAULT;
-
        memset(&tmp, 0, sizeof(tmp));
 
        tmp.type                = PORT_16550A;
index fce82fd79f77bf59db864c2d1f09e166aa5d018a..c339163698eb9960f8cc71735d8ed1cf24905e75 100644 (file)
@@ -2459,9 +2459,6 @@ static int get_serial_info(struct edgeport_port *edge_port,
        struct serial_struct tmp;
        unsigned cwait;
 
-       if (!retinfo)
-               return -EFAULT;
-
        cwait = edge_port->port->port.closing_wait;
        if (cwait != ASYNC_CLOSING_WAIT_NONE)
                cwait = jiffies_to_msecs(cwait) / 10;
index de9992b492b08ba447fb1f594e0a4f12f1d3c9a7..d52caa03679c6cbc5886316cb27d471d0c4b7bc4 100644 (file)
@@ -1861,9 +1861,6 @@ static int get_serial_info(struct moschip_port *mos7720_port,
 {
        struct serial_struct tmp;
 
-       if (!retinfo)
-               return -EFAULT;
-
        memset(&tmp, 0, sizeof(tmp));
 
        tmp.type                = PORT_16550A;
index 57426d703a098dd2d45d67de11acc0ccb5b2f3a5..9a220b8e810f161be985d9655ec6d9dee90147dc 100644 (file)
@@ -1956,9 +1956,6 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
        if (mos7840_port == NULL)
                return -1;
 
-       if (!retinfo)
-               return -EFAULT;
-
        memset(&tmp, 0, sizeof(tmp));
 
        tmp.type = PORT_16550A;
index 4b7bfb394a32aba025e8e07ad3384759ea1723d8..5ded6f524d59128e66e1864255515b5720d64921 100644 (file)
@@ -336,9 +336,6 @@ static int get_serial_info(struct usb_serial_port *port,
 {
        struct serial_struct tmp;
 
-       if (!serial)
-               return -EFAULT;
-
        memset(&tmp, 0x00, sizeof(tmp));
 
        /* fake emulate a 16550 uart to make userspace code happy */
index 85acb50a7ee2f4fe74ae26dc3dc96611cbd9d918..659cb8606bd953a7585a013beeb3dc3989400a14 100644 (file)
@@ -463,9 +463,6 @@ static int get_serial_info(struct usb_serial_port *port,
 {
        struct serial_struct tmp;
 
-       if (!retinfo)
-               return -EFAULT;
-
        memset(&tmp, 0, sizeof(tmp));
        tmp.line                = port->minor;
        tmp.port                = 0;
index 70a098de429fc39934ef8808d3e6c5011f063352..2a156144c76c51d907ba5b60b62ed72d7596dbad 100644 (file)
@@ -318,9 +318,6 @@ static int get_serial_info(struct usb_serial_port *port,
 {
        struct serial_struct tmp;
 
-       if (!retinfo)
-               return -EFAULT;
-
        memset(&tmp, 0, sizeof(tmp));
        tmp.line                = port->minor;
        tmp.port                = 0;
index a8b9bdba314fdc7bba899a29368f085f6d8a61ed..8db9d071d9409a9f6e85ce6b23a1515f90f11157 100644 (file)
@@ -1426,9 +1426,6 @@ static int ti_get_serial_info(struct ti_port *tport,
        struct serial_struct ret_serial;
        unsigned cwait;
 
-       if (!ret_arg)
-               return -EFAULT;
-
        cwait = port->port.closing_wait;
        if (cwait != ASYNC_CLOSING_WAIT_NONE)
                cwait = jiffies_to_msecs(cwait) / 10;
index 3dfdfc81254b827cc2e1f04feb926d0ad9666cf0..59bfcb3da116c4a49398750a1678f1d0349678fd 100644 (file)
@@ -140,9 +140,6 @@ static int get_serial_info(struct usb_serial_port *port,
 {
        struct serial_struct tmp;
 
-       if (!retinfo)
-               return -EFAULT;
-
        memset(&tmp, 0, sizeof(tmp));
        tmp.line            = port->minor;
        tmp.port            = port->port_number;