Skip to content

Commit c5f3378

Browse files
committed
Merge tag 'tty-5.7-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial fixes from Greg KH: "Here are some tty and serial driver fixes for 5.7-rc3. The "largest" in here are a number of reverts for previous changes to the uartps serial driver that turned out to not be a good idea at all. The others are just small fixes found by people and tools. Included in here is a much-reported symbol export needed by previous changes that happened in 5.7-rc1. All of these have been in linux-next for a while with no reported issues" * tag 'tty-5.7-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: tty: hvc: fix buffer overflow during hvc_alloc(). tty: rocket, avoid OOB access tty: serial: bcm63xx: fix missing clk_put() in bcm63xx_uart vt: don't hardcode the mem allocation upper bound tty: serial: owl: add "much needed" clk_prepare_enable() vt: don't use kmalloc() for the unicode screen buffer tty/sysrq: Export sysrq_mask(), sysrq_toggle_support() serial: sh-sci: Make sure status register SCxSR is read in correct sequence serial: sunhv: Initialize lock for non-registered console Revert "serial: uartps: Register own uart console and driver structures" Revert "serial: uartps: Move Port ID to device data structure" Revert "serial: uartps: Change uart ID port allocation" Revert "serial: uartps: Do not allow use aliases >= MAX_UART_INSTANCES" Revert "serial: uartps: Fix error path when alloc failed" Revert "serial: uartps: Use the same dynamic major number for all ports" Revert "serial: uartps: Fix uartps_major handling"
2 parents f6da8bd + 9a9fc42 commit c5f3378

File tree

9 files changed

+106
-189
lines changed

9 files changed

+106
-189
lines changed

drivers/tty/hvc/hvc_console.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,6 @@ int hvc_instantiate(uint32_t vtermno, int index, const struct hv_ops *ops)
302302
vtermnos[index] = vtermno;
303303
cons_ops[index] = ops;
304304

305-
/* reserve all indices up to and including this index */
306-
if (last_hvc < index)
307-
last_hvc = index;
308-
309305
/* check if we need to re-register the kernel console */
310306
hvc_check_console(index);
311307

@@ -960,13 +956,22 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
960956
cons_ops[i] == hp->ops)
961957
break;
962958

963-
/* no matching slot, just use a counter */
964-
if (i >= MAX_NR_HVC_CONSOLES)
965-
i = ++last_hvc;
959+
if (i >= MAX_NR_HVC_CONSOLES) {
960+
961+
/* find 'empty' slot for console */
962+
for (i = 0; i < MAX_NR_HVC_CONSOLES && vtermnos[i] != -1; i++) {
963+
}
964+
965+
/* no matching slot, just use a counter */
966+
if (i == MAX_NR_HVC_CONSOLES)
967+
i = ++last_hvc + MAX_NR_HVC_CONSOLES;
968+
}
966969

967970
hp->index = i;
968-
cons_ops[i] = ops;
969-
vtermnos[i] = vtermno;
971+
if (i < MAX_NR_HVC_CONSOLES) {
972+
cons_ops[i] = ops;
973+
vtermnos[i] = vtermno;
974+
}
970975

971976
list_add_tail(&(hp->next), &hvc_structs);
972977
mutex_unlock(&hvc_structs_mutex);

drivers/tty/rocket.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -632,18 +632,21 @@ init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
632632
tty_port_init(&info->port);
633633
info->port.ops = &rocket_port_ops;
634634
info->flags &= ~ROCKET_MODE_MASK;
635-
switch (pc104[board][line]) {
636-
case 422:
637-
info->flags |= ROCKET_MODE_RS422;
638-
break;
639-
case 485:
640-
info->flags |= ROCKET_MODE_RS485;
641-
break;
642-
case 232:
643-
default:
635+
if (board < ARRAY_SIZE(pc104) && line < ARRAY_SIZE(pc104_1))
636+
switch (pc104[board][line]) {
637+
case 422:
638+
info->flags |= ROCKET_MODE_RS422;
639+
break;
640+
case 485:
641+
info->flags |= ROCKET_MODE_RS485;
642+
break;
643+
case 232:
644+
default:
645+
info->flags |= ROCKET_MODE_RS232;
646+
break;
647+
}
648+
else
644649
info->flags |= ROCKET_MODE_RS232;
645-
break;
646-
}
647650

648651
info->intmask = RXF_TRIG | TXFIFO_MT | SRC_INT | DELTA_CD | DELTA_CTS | DELTA_DSR;
649652
if (sInitChan(ctlp, &info->channel, aiop, chan) == 0) {

drivers/tty/serial/bcm63xx_uart.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,10 @@ static int bcm_uart_probe(struct platform_device *pdev)
843843
if (IS_ERR(clk) && pdev->dev.of_node)
844844
clk = of_clk_get(pdev->dev.of_node, 0);
845845

846-
if (IS_ERR(clk))
846+
if (IS_ERR(clk)) {
847+
clk_put(clk);
847848
return -ENODEV;
849+
}
848850

849851
port->iotype = UPIO_MEM;
850852
port->irq = res_irq->start;

drivers/tty/serial/owl-uart.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,12 @@ static int owl_uart_probe(struct platform_device *pdev)
680680
return PTR_ERR(owl_port->clk);
681681
}
682682

683+
ret = clk_prepare_enable(owl_port->clk);
684+
if (ret) {
685+
dev_err(&pdev->dev, "could not enable clk\n");
686+
return ret;
687+
}
688+
683689
owl_port->port.dev = &pdev->dev;
684690
owl_port->port.line = pdev->id;
685691
owl_port->port.type = PORT_OWL;
@@ -712,6 +718,7 @@ static int owl_uart_remove(struct platform_device *pdev)
712718

713719
uart_remove_one_port(&owl_uart_driver, &owl_port->port);
714720
owl_uart_ports[pdev->id] = NULL;
721+
clk_disable_unprepare(owl_port->clk);
715722

716723
return 0;
717724
}

drivers/tty/serial/sh-sci.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,16 @@ static void sci_receive_chars(struct uart_port *port)
870870
tty_insert_flip_char(tport, c, TTY_NORMAL);
871871
} else {
872872
for (i = 0; i < count; i++) {
873-
char c = serial_port_in(port, SCxRDR);
874-
875-
status = serial_port_in(port, SCxSR);
873+
char c;
874+
875+
if (port->type == PORT_SCIF ||
876+
port->type == PORT_HSCIF) {
877+
status = serial_port_in(port, SCxSR);
878+
c = serial_port_in(port, SCxRDR);
879+
} else {
880+
c = serial_port_in(port, SCxRDR);
881+
status = serial_port_in(port, SCxSR);
882+
}
876883
if (uart_handle_sysrq_char(port, c)) {
877884
count--; i--;
878885
continue;

drivers/tty/serial/sunhv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,9 @@ static int hv_probe(struct platform_device *op)
567567
sunserial_console_match(&sunhv_console, op->dev.of_node,
568568
&sunhv_reg, port->line, false);
569569

570+
/* We need to initialize lock even for non-registered console */
571+
spin_lock_init(&port->lock);
572+
570573
err = uart_add_one_port(&sunhv_reg, port);
571574
if (err)
572575
goto out_unregister_driver;

0 commit comments

Comments
 (0)