]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tty: Always handle NULL flag ptr
authorPeter Hurley <peter@hurleysoftware.com>
Mon, 2 Dec 2013 18:56:03 +0000 (13:56 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 Dec 2013 00:56:05 +0000 (16:56 -0800)
Most line disciplines already handle the undocumented NULL flag
ptr in their .receive_buf method; however, several don't.

Document the NULL flag ptr, and correct handling in the
N_MOUSE, N_GSM0710 and N_R394 line disciplines.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/input/serio/serport.c
drivers/tty/n_gsm.c
drivers/tty/n_r3964.c
include/linux/tty_ldisc.h

index 8755f5f3ad37c2218de60b96782c0863615a705e..0cb7ef59071b792a350a914e88f4e9be7da34efc 100644 (file)
@@ -124,7 +124,7 @@ static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *c
 {
        struct serport *serport = (struct serport*) tty->disc_data;
        unsigned long flags;
-       unsigned int ch_flags;
+       unsigned int ch_flags = 0;
        int i;
 
        spin_lock_irqsave(&serport->lock, flags);
@@ -133,18 +133,20 @@ static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *c
                goto out;
 
        for (i = 0; i < count; i++) {
-               switch (fp[i]) {
-               case TTY_FRAME:
-                       ch_flags = SERIO_FRAME;
-                       break;
-
-               case TTY_PARITY:
-                       ch_flags = SERIO_PARITY;
-                       break;
-
-               default:
-                       ch_flags = 0;
-                       break;
+               if (fp) {
+                       switch (fp[i]) {
+                       case TTY_FRAME:
+                               ch_flags = SERIO_FRAME;
+                               break;
+
+                       case TTY_PARITY:
+                               ch_flags = SERIO_PARITY;
+                               break;
+
+                       default:
+                               ch_flags = 0;
+                               break;
+                       }
                }
 
                serio_interrupt(serport->serio, cp[i], ch_flags);
index c0f76da553042db2f3eadb91cfb9ff08bc60e43d..c09db11b8831d8b9f5b8b05413e0907a46ba1299 100644 (file)
@@ -2269,14 +2269,15 @@ static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
        char *f;
        int i;
        char buf[64];
-       char flags;
+       char flags = TTY_NORMAL;
 
        if (debug & 4)
                print_hex_dump_bytes("gsmld_receive: ", DUMP_PREFIX_OFFSET,
                                     cp, count);
 
        for (i = count, dp = cp, f = fp; i; i--, dp++) {
-               flags = *f++;
+               if (f)
+                       flags = *f++;
                switch (flags) {
                case TTY_NORMAL:
                        gsm->receive(gsm, *dp);
index 1e6405070ce649e356b24d272a824e9eda737159..8b157d68a03e97aa2089d9b3c4d98fdb0b109719 100644 (file)
@@ -1244,7 +1244,7 @@ static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 {
        struct r3964_info *pInfo = tty->disc_data;
        const unsigned char *p;
-       char *f, flags = 0;
+       char *f, flags = TTY_NORMAL;
        int i;
 
        for (i = count, p = cp, f = fp; i; i--, p++) {
index f15c898ff462006fb0bec91d5922ecbf24267d8c..b8347c207cb845d940ed163cb89776e0bacaf252 100644 (file)
@@ -84,7 +84,8 @@
  *     processing.  <cp> is a pointer to the buffer of input
  *     character received by the device.  <fp> is a pointer to a
  *     pointer of flag bytes which indicate whether a character was
- *     received with a parity error, etc.
+ *     received with a parity error, etc. <fp> may be NULL to indicate
+ *     all data received is TTY_NORMAL.
  *
  * void        (*write_wakeup)(struct tty_struct *);
  *
  *     processing.  <cp> is a pointer to the buffer of input
  *     character received by the device.  <fp> is a pointer to a
  *     pointer of flag bytes which indicate whether a character was
- *     received with a parity error, etc.
+ *     received with a parity error, etc. <fp> may be NULL to indicate
+ *     all data received is TTY_NORMAL.
  *     If assigned, prefer this function for automatic flow control.
  */