Skip to content

Commit e22a15d

Browse files
committed
Merge tag 'tty-5.0-rc6' 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 fixes for 5.0-rc6. Nothing huge, just a few small fixes for reported issues. The speakup fix is in here as it is a tty operation issue. All of these have been in linux-next for a while with no reported problems" * tag 'tty-5.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: serial: fix race between flush_to_ldisc and tty_open staging: speakup: fix tty-operation NULL derefs serial: sh-sci: Do not free irqs that have already been freed serial: 8250_pci: Make PCI class test non fatal tty: serial: 8250_mtk: Fix potential NULL pointer dereference
2 parents 00a159a + fedb576 commit e22a15d

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

drivers/staging/speakup/spk_ttyio.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ static void spk_ttyio_send_xchar(char ch)
265265
return;
266266
}
267267

268-
speakup_tty->ops->send_xchar(speakup_tty, ch);
268+
if (speakup_tty->ops->send_xchar)
269+
speakup_tty->ops->send_xchar(speakup_tty, ch);
269270
mutex_unlock(&speakup_tty_mutex);
270271
}
271272

@@ -277,7 +278,8 @@ static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear)
277278
return;
278279
}
279280

280-
speakup_tty->ops->tiocmset(speakup_tty, set, clear);
281+
if (speakup_tty->ops->tiocmset)
282+
speakup_tty->ops->tiocmset(speakup_tty, set, clear);
281283
mutex_unlock(&speakup_tty_mutex);
282284
}
283285

drivers/tty/serial/8250/8250_mtk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ static int mtk8250_probe_of(struct platform_device *pdev, struct uart_port *p,
357357
if (dmacnt == 2) {
358358
data->dma = devm_kzalloc(&pdev->dev, sizeof(*data->dma),
359359
GFP_KERNEL);
360+
if (!data->dma)
361+
return -ENOMEM;
362+
360363
data->dma->fn = mtk8250_dma_filter;
361364
data->dma->rx_size = MTK_UART_RX_SIZE;
362365
data->dma->rxconf.src_maxburst = MTK_UART_RX_TRIGGER;

drivers/tty/serial/8250/8250_pci.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,6 +3420,11 @@ static int
34203420
serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board)
34213421
{
34223422
int num_iomem, num_port, first_port = -1, i;
3423+
int rc;
3424+
3425+
rc = serial_pci_is_class_communication(dev);
3426+
if (rc)
3427+
return rc;
34233428

34243429
/*
34253430
* Should we try to make guesses for multiport serial devices later?
@@ -3647,10 +3652,6 @@ pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
36473652

36483653
board = &pci_boards[ent->driver_data];
36493654

3650-
rc = serial_pci_is_class_communication(dev);
3651-
if (rc)
3652-
return rc;
3653-
36543655
rc = serial_pci_is_blacklisted(dev);
36553656
if (rc)
36563657
return rc;

drivers/tty/serial/serial_core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ static void uart_start(struct tty_struct *tty)
130130
struct uart_port *port;
131131
unsigned long flags;
132132

133+
if (!state)
134+
return;
135+
133136
port = uart_port_lock(state, flags);
134137
__uart_start(tty);
135138
uart_port_unlock(port, flags);
@@ -727,6 +730,9 @@ static void uart_unthrottle(struct tty_struct *tty)
727730
upstat_t mask = UPSTAT_SYNC_FIFO;
728731
struct uart_port *port;
729732

733+
if (!state)
734+
return;
735+
730736
port = uart_port_ref(state);
731737
if (!port)
732738
return;

drivers/tty/serial/sh-sci.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ static int sci_request_irq(struct sci_port *port)
19211921

19221922
static void sci_free_irq(struct sci_port *port)
19231923
{
1924-
int i;
1924+
int i, j;
19251925

19261926
/*
19271927
* Intentionally in reverse order so we iterate over the muxed
@@ -1937,6 +1937,13 @@ static void sci_free_irq(struct sci_port *port)
19371937
if (unlikely(irq < 0))
19381938
continue;
19391939

1940+
/* Check if already freed (irq was muxed) */
1941+
for (j = 0; j < i; j++)
1942+
if (port->irqs[j] == irq)
1943+
j = i + 1;
1944+
if (j > i)
1945+
continue;
1946+
19401947
free_irq(port->irqs[i], port);
19411948
kfree(port->irqstr[i]);
19421949

0 commit comments

Comments
 (0)