From 2e3eda8cf15da64d48ff93a1943441987ac85780 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 26 Sep 2021 15:14:29 +0200 Subject: [PATCH] 4.9-stable patches added patches: net-hso-fix-muxed-tty-registration.patch serial-mvebu-uart-fix-driver-s-tx_empty-callback.patch --- .../net-hso-fix-muxed-tty-registration.patch | 59 +++++++++++++++++++ ...-uart-fix-driver-s-tx_empty-callback.patch | 44 ++++++++++++++ queue-4.9/series | 2 + 3 files changed, 105 insertions(+) create mode 100644 queue-4.9/net-hso-fix-muxed-tty-registration.patch create mode 100644 queue-4.9/serial-mvebu-uart-fix-driver-s-tx_empty-callback.patch diff --git a/queue-4.9/net-hso-fix-muxed-tty-registration.patch b/queue-4.9/net-hso-fix-muxed-tty-registration.patch new file mode 100644 index 00000000000..318eed0ef31 --- /dev/null +++ b/queue-4.9/net-hso-fix-muxed-tty-registration.patch @@ -0,0 +1,59 @@ +From e8f69b16ee776da88589b5271e3f46020efc8f6c Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Fri, 17 Sep 2021 12:12:04 +0200 +Subject: net: hso: fix muxed tty registration + +From: Johan Hovold + +commit e8f69b16ee776da88589b5271e3f46020efc8f6c upstream. + +If resource allocation and registration fail for a muxed tty device +(e.g. if there are no more minor numbers) the driver should not try to +deregister the never-registered (or already-deregistered) tty. + +Fix up the error handling to avoid dereferencing a NULL pointer when +attempting to remove the character device. + +Fixes: 72dc1c096c70 ("HSO: add option hso driver") +Cc: stable@vger.kernel.org # 2.6.27 +Signed-off-by: Johan Hovold +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/usb/hso.c | 12 +++++------- + 1 file changed, 5 insertions(+), 7 deletions(-) + +--- a/drivers/net/usb/hso.c ++++ b/drivers/net/usb/hso.c +@@ -2715,14 +2715,14 @@ struct hso_device *hso_create_mux_serial + + serial = kzalloc(sizeof(*serial), GFP_KERNEL); + if (!serial) +- goto exit; ++ goto err_free_dev; + + hso_dev->port_data.dev_serial = serial; + serial->parent = hso_dev; + + if (hso_serial_common_create + (serial, 1, CTRL_URB_RX_SIZE, CTRL_URB_TX_SIZE)) +- goto exit; ++ goto err_free_serial; + + serial->tx_data_length--; + serial->write_data = hso_mux_serial_write_data; +@@ -2738,11 +2738,9 @@ struct hso_device *hso_create_mux_serial + /* done, return it */ + return hso_dev; + +-exit: +- if (serial) { +- tty_unregister_device(tty_drv, serial->minor); +- kfree(serial); +- } ++err_free_serial: ++ kfree(serial); ++err_free_dev: + kfree(hso_dev); + return NULL; + diff --git a/queue-4.9/serial-mvebu-uart-fix-driver-s-tx_empty-callback.patch b/queue-4.9/serial-mvebu-uart-fix-driver-s-tx_empty-callback.patch new file mode 100644 index 00000000000..d07f6f0f939 --- /dev/null +++ b/queue-4.9/serial-mvebu-uart-fix-driver-s-tx_empty-callback.patch @@ -0,0 +1,44 @@ +From 74e1eb3b4a1ef2e564b4bdeb6e92afe844e900de Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pali=20Roh=C3=A1r?= +Date: Sat, 11 Sep 2021 15:20:17 +0200 +Subject: serial: mvebu-uart: fix driver's tx_empty callback +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Pali Rohár + +commit 74e1eb3b4a1ef2e564b4bdeb6e92afe844e900de upstream. + +Driver's tx_empty callback should signal when the transmit shift register +is empty. So when the last character has been sent. + +STAT_TX_FIFO_EMP bit signals only that HW transmit FIFO is empty, which +happens when the last byte is loaded into transmit shift register. + +STAT_TX_EMP bit signals when the both HW transmit FIFO and transmit shift +register are empty. + +So replace STAT_TX_FIFO_EMP check by STAT_TX_EMP in mvebu_uart_tx_empty() +callback function. + +Fixes: 30530791a7a0 ("serial: mvebu-uart: initial support for Armada-3700 serial port") +Cc: stable +Signed-off-by: Pali Rohár +Link: https://lore.kernel.org/r/20210911132017.25505-1-pali@kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/mvebu-uart.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/tty/serial/mvebu-uart.c ++++ b/drivers/tty/serial/mvebu-uart.c +@@ -108,7 +108,7 @@ static unsigned int mvebu_uart_tx_empty( + st = readl(port->membase + UART_STAT); + spin_unlock_irqrestore(&port->lock, flags); + +- return (st & STAT_TX_FIFO_EMP) ? TIOCSER_TEMT : 0; ++ return (st & STAT_TX_EMP) ? TIOCSER_TEMT : 0; + } + + static unsigned int mvebu_uart_get_mctrl(struct uart_port *port) diff --git a/queue-4.9/series b/queue-4.9/series index 530c5d2db9b..c49f5e66b6a 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -11,3 +11,5 @@ usb-serial-option-add-telit-ln920-compositions.patch usb-serial-option-remove-duplicate-usb-device-id.patch usb-serial-option-add-device-id-for-foxconn-t99w265.patch mcb-fix-error-handling-in-mcb_alloc_bus.patch +serial-mvebu-uart-fix-driver-s-tx_empty-callback.patch +net-hso-fix-muxed-tty-registration.patch -- 2.47.3