Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'tty-5.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty/serial fixes from Greg KH:
"Here are some small TTY and Serial driver fixes for reported issues
for 5.10-rc2. They include:

- vt ioctl bugfix for reported problems

- fsl_lpuart serial driver fix

- 21285 serial driver bugfix

All have been in linux-next with no reported issues"

* tag 'tty-5.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
vt_ioctl: fix GIO_UNIMAP regression
vt: keyboard, extend func_buf_lock to readers
vt: keyboard, simplify vt_kdgkbsent
tty: serial: fsl_lpuart: LS1021A has a FIFO size of 16 words, like LS1028A
tty: serial: 21285: fix lockup on open

+37 -38
+6 -6
drivers/tty/serial/21285.c
··· 50 50 51 51 static bool is_enabled(struct uart_port *port, int bit) 52 52 { 53 - unsigned long private_data = (unsigned long)port->private_data; 53 + unsigned long *private_data = (unsigned long *)&port->private_data; 54 54 55 - if (test_bit(bit, &private_data)) 55 + if (test_bit(bit, private_data)) 56 56 return true; 57 57 return false; 58 58 } 59 59 60 60 static void enable(struct uart_port *port, int bit) 61 61 { 62 - unsigned long private_data = (unsigned long)port->private_data; 62 + unsigned long *private_data = (unsigned long *)&port->private_data; 63 63 64 - set_bit(bit, &private_data); 64 + set_bit(bit, private_data); 65 65 } 66 66 67 67 static void disable(struct uart_port *port, int bit) 68 68 { 69 - unsigned long private_data = (unsigned long)port->private_data; 69 + unsigned long *private_data = (unsigned long *)&port->private_data; 70 70 71 - clear_bit(bit, &private_data); 71 + clear_bit(bit, private_data); 72 72 } 73 73 74 74 #define is_tx_enabled(port) is_enabled(port, tx_enabled_bit)
+7 -6
drivers/tty/serial/fsl_lpuart.c
··· 314 314 /* Forward declare this for the dma callbacks*/ 315 315 static void lpuart_dma_tx_complete(void *arg); 316 316 317 - static inline bool is_ls1028a_lpuart(struct lpuart_port *sport) 317 + static inline bool is_layerscape_lpuart(struct lpuart_port *sport) 318 318 { 319 - return sport->devtype == LS1028A_LPUART; 319 + return (sport->devtype == LS1021A_LPUART || 320 + sport->devtype == LS1028A_LPUART); 320 321 } 321 322 322 323 static inline bool is_imx8qxp_lpuart(struct lpuart_port *sport) ··· 1702 1701 UARTFIFO_FIFOSIZE_MASK); 1703 1702 1704 1703 /* 1705 - * The LS1028A has a fixed length of 16 words. Although it supports the 1706 - * RX/TXSIZE fields their encoding is different. Eg the reference manual 1707 - * states 0b101 is 16 words. 1704 + * The LS1021A and LS1028A have a fixed FIFO depth of 16 words. 1705 + * Although they support the RX/TXSIZE fields, their encoding is 1706 + * different. Eg the reference manual states 0b101 is 16 words. 1708 1707 */ 1709 - if (is_ls1028a_lpuart(sport)) { 1708 + if (is_layerscape_lpuart(sport)) { 1710 1709 sport->rxfifo_size = 16; 1711 1710 sport->txfifo_size = 16; 1712 1711 sport->port.fifosize = sport->txfifo_size;
+19 -20
drivers/tty/vt/keyboard.c
··· 743 743 return; 744 744 745 745 if ((unsigned)value < ARRAY_SIZE(func_table)) { 746 + unsigned long flags; 747 + 748 + spin_lock_irqsave(&func_buf_lock, flags); 746 749 if (func_table[value]) 747 750 puts_queue(vc, func_table[value]); 751 + spin_unlock_irqrestore(&func_buf_lock, flags); 752 + 748 753 } else 749 754 pr_err("k_fn called with value=%d\n", value); 750 755 } ··· 1996 1991 #undef s 1997 1992 #undef v 1998 1993 1999 - /* FIXME: This one needs untangling and locking */ 1994 + /* FIXME: This one needs untangling */ 2000 1995 int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) 2001 1996 { 2002 1997 struct kbsentry *kbs; 2003 - char *p; 2004 1998 u_char *q; 2005 - u_char __user *up; 2006 1999 int sz, fnw_sz; 2007 2000 int delta; 2008 2001 char *first_free, *fj, *fnw; ··· 2026 2023 i = array_index_nospec(kbs->kb_func, MAX_NR_FUNC); 2027 2024 2028 2025 switch (cmd) { 2029 - case KDGKBSENT: 2030 - sz = sizeof(kbs->kb_string) - 1; /* sz should have been 2031 - a struct member */ 2032 - up = user_kdgkb->kb_string; 2033 - p = func_table[i]; 2034 - if(p) 2035 - for ( ; *p && sz; p++, sz--) 2036 - if (put_user(*p, up++)) { 2037 - ret = -EFAULT; 2038 - goto reterr; 2039 - } 2040 - if (put_user('\0', up)) { 2041 - ret = -EFAULT; 2042 - goto reterr; 2043 - } 2044 - kfree(kbs); 2045 - return ((p && *p) ? -EOVERFLOW : 0); 2026 + case KDGKBSENT: { 2027 + /* size should have been a struct member */ 2028 + ssize_t len = sizeof(user_kdgkb->kb_string); 2029 + 2030 + spin_lock_irqsave(&func_buf_lock, flags); 2031 + len = strlcpy(kbs->kb_string, func_table[i] ? : "", len); 2032 + spin_unlock_irqrestore(&func_buf_lock, flags); 2033 + 2034 + ret = copy_to_user(user_kdgkb->kb_string, kbs->kb_string, 2035 + len + 1) ? -EFAULT : 0; 2036 + 2037 + goto reterr; 2038 + } 2046 2039 case KDSKBSENT: 2047 2040 if (!perm) { 2048 2041 ret = -EPERM;
+5 -6
drivers/tty/vt/vt_ioctl.c
··· 549 549 } 550 550 551 551 static inline int do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, 552 - struct vc_data *vc) 552 + bool perm, struct vc_data *vc) 553 553 { 554 554 struct unimapdesc tmp; 555 555 ··· 557 557 return -EFAULT; 558 558 switch (cmd) { 559 559 case PIO_UNIMAP: 560 + if (!perm) 561 + return -EPERM; 560 562 return con_set_unimap(vc, tmp.entry_ct, tmp.entries); 561 563 case GIO_UNIMAP: 562 - if (fg_console != vc->vc_num) 564 + if (!perm && fg_console != vc->vc_num) 563 565 return -EPERM; 564 566 return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct), 565 567 tmp.entries); ··· 641 639 642 640 case PIO_UNIMAP: 643 641 case GIO_UNIMAP: 644 - if (!perm) 645 - return -EPERM; 646 - 647 - return do_unimap_ioctl(cmd, up, vc); 642 + return do_unimap_ioctl(cmd, up, perm, vc); 648 643 649 644 default: 650 645 return -ENOIOCTLCMD;