Merge tag 'tty-3.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
[firefly-linux-kernel-4.4.55.git] / drivers / staging / dgrp / dgrp_tty.c
index efa62ced7c8a9b4f8a60a91ed61b49d7fe263884..51d3ed3dca277e2d0cb1cf5d63a19711d996d6a2 100644 (file)
@@ -432,7 +432,7 @@ static void drp_param(struct ch_struct *ch)
        /*
         * From the POSIX.1 spec (7.1.2.6): "If {_POSIX_VDISABLE}
         * is defined for the terminal device file, and the value
-        * of one of the changable special control characters (see
+        * of one of the changeable special control characters (see
         * 7.1.1.9) is {_POSIX_VDISABLE}, that function shall be
         * disabled, that is, no input data shall be recognized as
         * the disabled special character."
@@ -2265,9 +2265,7 @@ static int get_modem_info(struct ch_struct *ch, unsigned int *value)
                | ((mlast & DM_RI)  ? TIOCM_RNG : 0)
                | ((mlast & DM_DSR) ? TIOCM_DSR : 0)
                | ((mlast & DM_CTS) ? TIOCM_CTS : 0);
-       put_user(mlast, (unsigned int __user *) value);
-
-       return 0;
+       return put_user(mlast, (unsigned int __user *) value);
 }
 
 /*
@@ -2285,7 +2283,8 @@ static int set_modem_info(struct ch_struct *ch, unsigned int command,
        if (error == 0)
                return -EFAULT;
 
-       get_user(arg, (unsigned int __user *) value);
+       if (get_user(arg, (unsigned int __user *) value))
+               return -EFAULT;
        mval |= ((arg & TIOCM_RTS) ? DM_RTS : 0)
                | ((arg & TIOCM_DTR) ? DM_DTR : 0);
 
@@ -2684,7 +2683,7 @@ static int dgrp_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
        - looking at the tty_ioctl code, these command all call our
        tty_set_termios at the driver's end, when a TCSETA* is sent,
        it is expecting the tty to have a termio structure,
-       NOT a termios stucture.  These two structures differ in size
+       NOT a termios structure.  These two structures differ in size
        and the tty_ioctl code does a conversion before processing them both.
        - we should treat the TCSETAW TCSETAF ioctls the same, and let
        the tty_ioctl code do the conversion stuff.
@@ -2836,17 +2835,16 @@ static int dgrp_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
                break;
 
        case DIGI_GETCUSTOMBAUD:
-               rc = access_ok(VERIFY_WRITE, (void __user *) arg, sizeof(int));
-               if (rc == 0)
+               if (put_user(ch->ch_custom_speed, (unsigned int __user *) arg))
                        return -EFAULT;
-               put_user(ch->ch_custom_speed, (unsigned int __user *) arg);
                break;
 
        case DIGI_SETCUSTOMBAUD:
        {
                int new_rate;
 
-               get_user(new_rate, (unsigned int __user *) arg);
+               if (get_user(new_rate, (unsigned int __user *) arg))
+                       return -EFAULT;
                dgrp_set_custom_speed(ch, new_rate);
 
                break;
@@ -2981,7 +2979,7 @@ static void dgrp_tty_start(struct tty_struct *tty)
 }
 
 /*
- *     Stop the reciever
+ *     Stop the receiver
  */
 static void dgrp_tty_input_stop(struct tty_struct *tty)
 {
@@ -3104,6 +3102,7 @@ static void dgrp_tty_hangup(struct tty_struct *tty)
 void
 dgrp_tty_uninit(struct nd_struct *nd)
 {
+       unsigned int i;
        char id[3];
 
        ID_TO_CHAR(nd->nd_ID, id);
@@ -3137,6 +3136,8 @@ dgrp_tty_uninit(struct nd_struct *nd)
                put_tty_driver(nd->nd_xprint_ttdriver);
                nd->nd_ttdriver_flags &= ~XPRINT_TTDRV_REG;
        }
+       for (i = 0; i < CHAN_MAX; i++)
+               tty_port_destroy(&nd->nd_chan[i].port);
 }
 
 
@@ -3320,7 +3321,6 @@ dgrp_tty_init(struct nd_struct *nd)
                init_waitqueue_head(&(ch->ch_pun.un_open_wait));
                init_waitqueue_head(&(ch->ch_pun.un_close_wait));
                tty_port_init(&ch->port);
-               tty_port_init(&ch->port);
        }
        return 0;
 }