Skip to content

Commit 15bc20c

Browse files
committed
Merge tag 'tty-5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial fixes from Greg KH: "Here are a few small TTY/Serial/vt fixes for 5.9-rc3 Included in here are: - qcom serial fixes - vt ioctl and core bugfixes - pl011 serial driver fixes - 8250 serial driver fixes - other misc serial driver fixes and for good measure: - fbcon fix for syzbot found problem. All of these have been in linux-next for a while with no reported issues" * tag 'tty-5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: tty: serial: imx: add dependence and build for earlycon serial: samsung: Removes the IRQ not found warning serial: 8250: change lock order in serial8250_do_startup() serial: stm32: avoid kernel warning on absence of optional IRQ serial: pl011: Fix oops on -EPROBE_DEFER serial: pl011: Don't leak amba_ports entry on driver register error serial: 8250_exar: Fix number of ports for Commtech PCIe cards tty: serial: qcom_geni_serial: Drop __init from qcom_geni_console_setup serial: qcom_geni_serial: Fix recent kdb hang vt_ioctl: change VT_RESIZEX ioctl to check for error return from vc_resize() fbcon: prevent user font height or width change from causing potential out-of-bounds access vt: defer kfree() of vc_screenbuf in vc_do_resize()
2 parents 27563ab + ea1fc02 commit 15bc20c

11 files changed

Lines changed: 89 additions & 25 deletions

File tree

drivers/tty/serial/8250/8250_exar.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,24 @@ static const struct exar8250_board pbn_exar_XR17V35x = {
744744
.exit = pci_xr17v35x_exit,
745745
};
746746

747+
static const struct exar8250_board pbn_fastcom35x_2 = {
748+
.num_ports = 2,
749+
.setup = pci_xr17v35x_setup,
750+
.exit = pci_xr17v35x_exit,
751+
};
752+
753+
static const struct exar8250_board pbn_fastcom35x_4 = {
754+
.num_ports = 4,
755+
.setup = pci_xr17v35x_setup,
756+
.exit = pci_xr17v35x_exit,
757+
};
758+
759+
static const struct exar8250_board pbn_fastcom35x_8 = {
760+
.num_ports = 8,
761+
.setup = pci_xr17v35x_setup,
762+
.exit = pci_xr17v35x_exit,
763+
};
764+
747765
static const struct exar8250_board pbn_exar_XR17V4358 = {
748766
.num_ports = 12,
749767
.setup = pci_xr17v35x_setup,
@@ -811,9 +829,9 @@ static const struct pci_device_id exar_pci_tbl[] = {
811829
EXAR_DEVICE(EXAR, XR17V358, pbn_exar_XR17V35x),
812830
EXAR_DEVICE(EXAR, XR17V4358, pbn_exar_XR17V4358),
813831
EXAR_DEVICE(EXAR, XR17V8358, pbn_exar_XR17V8358),
814-
EXAR_DEVICE(COMMTECH, 4222PCIE, pbn_exar_XR17V35x),
815-
EXAR_DEVICE(COMMTECH, 4224PCIE, pbn_exar_XR17V35x),
816-
EXAR_DEVICE(COMMTECH, 4228PCIE, pbn_exar_XR17V35x),
832+
EXAR_DEVICE(COMMTECH, 4222PCIE, pbn_fastcom35x_2),
833+
EXAR_DEVICE(COMMTECH, 4224PCIE, pbn_fastcom35x_4),
834+
EXAR_DEVICE(COMMTECH, 4228PCIE, pbn_fastcom35x_8),
817835

818836
EXAR_DEVICE(COMMTECH, 4222PCI335, pbn_fastcom335_2),
819837
EXAR_DEVICE(COMMTECH, 4224PCI335, pbn_fastcom335_4),

drivers/tty/serial/8250/8250_port.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,10 @@ int serial8250_do_startup(struct uart_port *port)
22752275

22762276
if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) {
22772277
unsigned char iir1;
2278+
2279+
if (port->irqflags & IRQF_SHARED)
2280+
disable_irq_nosync(port->irq);
2281+
22782282
/*
22792283
* Test for UARTs that do not reassert THRE when the
22802284
* transmitter is idle and the interrupt has already
@@ -2284,8 +2288,6 @@ int serial8250_do_startup(struct uart_port *port)
22842288
* allow register changes to become visible.
22852289
*/
22862290
spin_lock_irqsave(&port->lock, flags);
2287-
if (up->port.irqflags & IRQF_SHARED)
2288-
disable_irq_nosync(port->irq);
22892291

22902292
wait_for_xmitr(up, UART_LSR_THRE);
22912293
serial_port_out_sync(port, UART_IER, UART_IER_THRI);
@@ -2297,9 +2299,10 @@ int serial8250_do_startup(struct uart_port *port)
22972299
iir = serial_port_in(port, UART_IIR);
22982300
serial_port_out(port, UART_IER, 0);
22992301

2302+
spin_unlock_irqrestore(&port->lock, flags);
2303+
23002304
if (port->irqflags & IRQF_SHARED)
23012305
enable_irq(port->irq);
2302-
spin_unlock_irqrestore(&port->lock, flags);
23032306

23042307
/*
23052308
* If the interrupt is not reasserted, or we otherwise

drivers/tty/serial/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ config SERIAL_IMX_CONSOLE
517517

518518
config SERIAL_IMX_EARLYCON
519519
bool "Earlycon on IMX serial port"
520+
depends on ARCH_MXC || COMPILE_TEST
520521
depends on OF
521522
select SERIAL_EARLYCON
522523
help

drivers/tty/serial/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ obj-$(CONFIG_SERIAL_ZS) += zs.o
4343
obj-$(CONFIG_SERIAL_SH_SCI) += sh-sci.o
4444
obj-$(CONFIG_SERIAL_CPM) += cpm_uart/
4545
obj-$(CONFIG_SERIAL_IMX) += imx.o
46+
obj-$(CONFIG_SERIAL_IMX_EARLYCON) += imx_earlycon.o
4647
obj-$(CONFIG_SERIAL_MPC52xx) += mpc52xx_uart.o
4748
obj-$(CONFIG_SERIAL_ICOM) += icom.o
4849
obj-$(CONFIG_SERIAL_MESON) += meson_uart.o

drivers/tty/serial/amba-pl011.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,9 +2241,8 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
22412241
clk_disable(uap->clk);
22422242
}
22432243

2244-
static void __init
2245-
pl011_console_get_options(struct uart_amba_port *uap, int *baud,
2246-
int *parity, int *bits)
2244+
static void pl011_console_get_options(struct uart_amba_port *uap, int *baud,
2245+
int *parity, int *bits)
22472246
{
22482247
if (pl011_read(uap, REG_CR) & UART01x_CR_UARTEN) {
22492248
unsigned int lcr_h, ibrd, fbrd;
@@ -2276,7 +2275,7 @@ pl011_console_get_options(struct uart_amba_port *uap, int *baud,
22762275
}
22772276
}
22782277

2279-
static int __init pl011_console_setup(struct console *co, char *options)
2278+
static int pl011_console_setup(struct console *co, char *options)
22802279
{
22812280
struct uart_amba_port *uap;
22822281
int baud = 38400;
@@ -2344,8 +2343,8 @@ static int __init pl011_console_setup(struct console *co, char *options)
23442343
*
23452344
* Returns 0 if console matches; otherwise non-zero to use default matching
23462345
*/
2347-
static int __init pl011_console_match(struct console *co, char *name, int idx,
2348-
char *options)
2346+
static int pl011_console_match(struct console *co, char *name, int idx,
2347+
char *options)
23492348
{
23502349
unsigned char iotype;
23512350
resource_size_t addr;
@@ -2615,7 +2614,7 @@ static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap,
26152614

26162615
static int pl011_register_port(struct uart_amba_port *uap)
26172616
{
2618-
int ret;
2617+
int ret, i;
26192618

26202619
/* Ensure interrupts from this UART are masked and cleared */
26212620
pl011_write(0, uap, REG_IMSC);
@@ -2626,6 +2625,9 @@ static int pl011_register_port(struct uart_amba_port *uap)
26262625
if (ret < 0) {
26272626
dev_err(uap->port.dev,
26282627
"Failed to register AMBA-PL011 driver\n");
2628+
for (i = 0; i < ARRAY_SIZE(amba_ports); i++)
2629+
if (amba_ports[i] == uap)
2630+
amba_ports[i] = NULL;
26292631
return ret;
26302632
}
26312633
}

drivers/tty/serial/qcom_geni_serial.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,16 @@ static int qcom_geni_serial_get_char(struct uart_port *uport)
361361
return NO_POLL_CHAR;
362362

363363
if (word_cnt == 1 && (status & RX_LAST))
364+
/*
365+
* NOTE: If RX_LAST_BYTE_VALID is 0 it needs to be
366+
* treated as if it was BYTES_PER_FIFO_WORD.
367+
*/
364368
private_data->poll_cached_bytes_cnt =
365369
(status & RX_LAST_BYTE_VALID_MSK) >>
366370
RX_LAST_BYTE_VALID_SHFT;
367-
else
368-
private_data->poll_cached_bytes_cnt = 4;
371+
372+
if (private_data->poll_cached_bytes_cnt == 0)
373+
private_data->poll_cached_bytes_cnt = BYTES_PER_FIFO_WORD;
369374

370375
private_data->poll_cached_bytes =
371376
readl(uport->membase + SE_GENI_RX_FIFOn);
@@ -1098,7 +1103,7 @@ static unsigned int qcom_geni_serial_tx_empty(struct uart_port *uport)
10981103
}
10991104

11001105
#ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE
1101-
static int __init qcom_geni_console_setup(struct console *co, char *options)
1106+
static int qcom_geni_console_setup(struct console *co, char *options)
11021107
{
11031108
struct uart_port *uport;
11041109
struct qcom_geni_serial_port *port;

drivers/tty/serial/samsung_tty.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,9 +1905,11 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
19051905
ourport->tx_irq = ret + 1;
19061906
}
19071907

1908-
ret = platform_get_irq(platdev, 1);
1909-
if (ret > 0)
1910-
ourport->tx_irq = ret;
1908+
if (!s3c24xx_serial_has_interrupt_mask(port)) {
1909+
ret = platform_get_irq(platdev, 1);
1910+
if (ret > 0)
1911+
ourport->tx_irq = ret;
1912+
}
19111913
/*
19121914
* DMA is currently supported only on DT platforms, if DMA properties
19131915
* are specified.

drivers/tty/serial/stm32-usart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ static int stm32_init_port(struct stm32_port *stm32port,
970970
return ret;
971971

972972
if (stm32port->info->cfg.has_wakeup) {
973-
stm32port->wakeirq = platform_get_irq(pdev, 1);
973+
stm32port->wakeirq = platform_get_irq_optional(pdev, 1);
974974
if (stm32port->wakeirq <= 0 && stm32port->wakeirq != -ENXIO)
975975
return stm32port->wakeirq ? : -ENODEV;
976976
}

drivers/tty/vt/vt.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
12011201
unsigned int old_rows, old_row_size, first_copied_row;
12021202
unsigned int new_cols, new_rows, new_row_size, new_screen_size;
12031203
unsigned int user;
1204-
unsigned short *newscreen;
1204+
unsigned short *oldscreen, *newscreen;
12051205
struct uni_screen *new_uniscr = NULL;
12061206

12071207
WARN_CONSOLE_UNLOCKED();
@@ -1299,10 +1299,11 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
12991299
if (new_scr_end > new_origin)
13001300
scr_memsetw((void *)new_origin, vc->vc_video_erase_char,
13011301
new_scr_end - new_origin);
1302-
kfree(vc->vc_screenbuf);
1302+
oldscreen = vc->vc_screenbuf;
13031303
vc->vc_screenbuf = newscreen;
13041304
vc->vc_screenbuf_size = new_screen_size;
13051305
set_origin(vc);
1306+
kfree(oldscreen);
13061307

13071308
/* do part of a reset_terminal() */
13081309
vc->vc_top = 0;

drivers/tty/vt/vt_ioctl.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,12 +806,22 @@ static int vt_resizex(struct vc_data *vc, struct vt_consize __user *cs)
806806
console_lock();
807807
vcp = vc_cons[i].d;
808808
if (vcp) {
809+
int ret;
810+
int save_scan_lines = vcp->vc_scan_lines;
811+
int save_font_height = vcp->vc_font.height;
812+
809813
if (v.v_vlin)
810814
vcp->vc_scan_lines = v.v_vlin;
811815
if (v.v_clin)
812816
vcp->vc_font.height = v.v_clin;
813817
vcp->vc_resize_user = 1;
814-
vc_resize(vcp, v.v_cols, v.v_rows);
818+
ret = vc_resize(vcp, v.v_cols, v.v_rows);
819+
if (ret) {
820+
vcp->vc_scan_lines = save_scan_lines;
821+
vcp->vc_font.height = save_font_height;
822+
console_unlock();
823+
return ret;
824+
}
815825
}
816826
console_unlock();
817827
}

0 commit comments

Comments
 (0)