All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Johan Hovold <johan@kernel.org>, Sasha Levin <sashal@kernel.org>,
	linux-usb@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 053/244] USB: serial: fix initial-termios handling
Date: Wed, 22 May 2019 15:23:19 -0400	[thread overview]
Message-ID: <20190522192630.24917-53-sashal@kernel.org> (raw)
In-Reply-To: <20190522192630.24917-1-sashal@kernel.org>

From: Johan Hovold <johan@kernel.org>

[ Upstream commit 579bebe5dd522580019e7b10b07daaf500f9fb1e ]

The USB-serial driver init_termios callback is used to override the
default initial terminal settings provided by USB-serial core.

After a bug was fixed in the original implementation introduced by
commit fe1ae7fdd2ee ("tty: USB serial termios bits"), the init_termios
callback was no longer called just once on first use as intended but
rather on every (first) open.

This specifically meant that the terminal settings saved on (final)
close were ignored when reopening a port for drivers overriding the
initial settings.

Also update the outdated function header referring to the creation of
termios objects.

Fixes: 7e29bb4b779f ("usb-serial: fix termios initialization logic")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/serial/usb-serial.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index f7aaa7f079e1a..c709b6281df65 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -164,9 +164,9 @@ void usb_serial_put(struct usb_serial *serial)
  * @driver: the driver (USB in our case)
  * @tty: the tty being created
  *
- * Create the termios objects for this tty.  We use the default
+ * Initialise the termios structure for this tty.  We use the default
  * USB serial settings but permit them to be overridden by
- * serial->type->init_termios.
+ * serial->type->init_termios on first open.
  *
  * This is the first place a new tty gets used.  Hence this is where we
  * acquire references to the usb_serial structure and the driver module,
@@ -178,6 +178,7 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
 	int idx = tty->index;
 	struct usb_serial *serial;
 	struct usb_serial_port *port;
+	bool init_termios;
 	int retval = -ENODEV;
 
 	port = usb_serial_port_get_by_minor(idx);
@@ -192,14 +193,16 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
 	if (retval)
 		goto error_get_interface;
 
+	init_termios = (driver->termios[idx] == NULL);
+
 	retval = tty_standard_install(driver, tty);
 	if (retval)
 		goto error_init_termios;
 
 	mutex_unlock(&serial->disc_mutex);
 
-	/* allow the driver to update the settings */
-	if (serial->type->init_termios)
+	/* allow the driver to update the initial settings */
+	if (init_termios && serial->type->init_termios)
 		serial->type->init_termios(tty);
 
 	tty->driver_data = port;
-- 
2.20.1


  parent reply	other threads:[~2019-05-22 19:45 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 19:22 [PATCH AUTOSEL 4.19 001/244] gfs2: Fix lru_count going negative Sasha Levin
2019-05-22 19:22 ` [Cluster-devel] " Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 002/244] cxgb4: Fix error path in cxgb4_init_module Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 003/244] NFS: make nfs_match_client killable Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 004/244] IB/hfi1: Fix WQ_MEM_RECLAIM warning Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 005/244] gfs2: Fix occasional glock use-after-free Sasha Levin
2019-05-22 19:22   ` [Cluster-devel] " Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 006/244] mmc: core: Verify SD bus width Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 007/244] batman-adv: mcast: fix multicast tt/tvlv worker locking Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 008/244] tools/bpf: fix perf build error with uClibc (seen on ARC) Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 009/244] selftests/bpf: set RLIMIT_MEMLOCK properly for test_libbpf_open.c Sasha Levin
2019-05-22 19:22   ` Sasha Levin
2019-05-22 19:22   ` sashal
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 010/244] bpftool: exclude bash-completion/bpftool from .gitignore pattern Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 011/244] dmaengine: tegra210-dma: free dma controller in remove() Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 012/244] net: ena: gcc 8: fix compilation warning Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 013/244] hv_netvsc: fix race that may miss tx queue wakeup Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 014/244] orangefs: truncate before updating size Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 015/244] Bluetooth: Ignore CC events not matching the last HCI command Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 016/244] pinctrl: zte: fix leaked of_node references Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 017/244] ASoC: Intel: kbl_da7219_max98357a: Map BTN_0 to KEY_PLAYPAUSE Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 018/244] usb: dwc2: gadget: Increase descriptors count for ISOC's Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 019/244] usb: dwc3: move synchronize_irq() out of the spinlock protected block Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 020/244] ASoC: hdmi-codec: unlock the device on startup errors Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 021/244] leds: avoid races with workqueue Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 022/244] powerpc/perf: Return accordingly on invalid chip-id in Sasha Levin
2019-05-22 19:22   ` Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 023/244] powerpc/boot: Fix missing check of lseek() return value Sasha Levin
2019-05-22 19:22   ` Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 024/244] powerpc/perf: Fix loop exit condition in nest_imc_event_init Sasha Levin
2019-05-22 19:22   ` Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 025/244] ASoC: imx: fix fiq dependencies Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 026/244] spi: pxa2xx: fix SCR (divisor) calculation Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 027/244] brcm80211: potential NULL dereference in brcmf_cfg80211_vndr_cmds_dcmd_handler() Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 028/244] ACPI / property: fix handling of data_nodes in acpi_get_next_subnode() Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 029/244] drm/nouveau/bar/nv50: ensure BAR is mapped Sasha Levin
2019-05-22 19:22   ` Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 030/244] media: stm32-dcmi: return appropriate error codes during probe Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 031/244] ARM: vdso: Remove dependency with the arch_timer driver internals Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 032/244] arm64: Fix compiler warning from pte_unmap() with -Wunused-but-set-variable Sasha Levin
2019-05-22 19:22 ` [PATCH AUTOSEL 4.19 033/244] powerpc/watchdog: Use hrtimers for per-CPU heartbeat Sasha Levin
2019-05-22 19:22   ` Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 034/244] sched/cpufreq: Fix kobject memleak Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 035/244] scsi: qla2xxx: Fix a qla24xx_enable_msix() error path Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 036/244] scsi: qla2xxx: Fix abort handling in tcm_qla2xxx_write_pending() Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 037/244] scsi: qla2xxx: Avoid that lockdep complains about unsafe locking in tcm_qla2xxx_close_session() Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 038/244] scsi: qla2xxx: Fix hardirq-unsafe locking Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 039/244] x86/modules: Avoid breaking W^X while loading modules Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 040/244] Btrfs: fix data bytes_may_use underflow with fallocate due to failed quota reserve Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 041/244] btrfs: fix panic during relocation after ENOSPC before writeback happens Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 042/244] btrfs: Don't panic when we can't find a root key Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 043/244] iwlwifi: pcie: don't crash on invalid RX interrupt Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 044/244] rtc: 88pm860x: prevent use-after-free on device remove Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 045/244] rtc: stm32: manage the get_irq probe defer case Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 046/244] scsi: qedi: Abort ep termination if offload not scheduled Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 047/244] s390/kexec_file: Fix detection of text segment in ELF loader Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 048/244] sched/nohz: Run NOHZ idle load balancer on HK_FLAG_MISC CPUs Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 049/244] w1: fix the resume command API Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 050/244] s390: qeth: address type mismatch warning Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 051/244] dmaengine: pl330: _stop: clear interrupt status Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 052/244] mac80211/cfg80211: update bss channel on channel switch Sasha Levin
2019-05-22 19:23 ` Sasha Levin [this message]
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 054/244] libbpf: fix samples/bpf build failure due to undefined UINT32_MAX Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 055/244] slimbus: fix a potential NULL pointer dereference in of_qcom_slim_ngd_register Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 056/244] driver core: platform: Fix the usage of platform device name(pdev->name) Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 057/244] ASoC: fsl_sai: Update is_slave_mode with correct value Sasha Levin
2019-05-22 19:23   ` Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 058/244] mwifiex: prevent an array overflow Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 059/244] rsi: Fix NULL pointer dereference in kmalloc Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 060/244] net: cw1200: fix a NULL pointer dereference Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 061/244] at76c50x-usb: Don't register led_trigger if usb_register_driver failed Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 062/244] nvme: set 0 capacity if namespace block size exceeds PAGE_SIZE Sasha Levin
2019-05-22 19:23   ` Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 063/244] nvme-rdma: fix a NULL deref when an admin connect times out Sasha Levin
2019-05-22 19:23   ` Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 064/244] ssb: Fix possible NULL pointer dereference in ssb_host_pcmcia_exit Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 065/244] crypto: sun4i-ss - Fix invalid calculation of hash end Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 066/244] bcache: avoid potential memleak of list of journal_replay(s) in the CACHE_SYNC branch of run_cache_set Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 067/244] bcache: return error immediately in bch_journal_replay() Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 068/244] bcache: fix failure in journal relplay Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 069/244] bcache: add failure check to run_cache_set() for journal replay Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 070/244] bcache: avoid clang -Wunintialized warning Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 071/244] RDMA/cma: Consider scope_id while binding to ipv6 ll address Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 072/244] vfio-ccw: Do not call flush_workqueue while holding the spinlock Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 073/244] vfio-ccw: Release any channel program when releasing/removing vfio-ccw mdev Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 074/244] x86/build: Move _etext to actual end of .text Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 075/244] smpboot: Place the __percpu annotation correctly Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 076/244] x86/mm: Remove in_nmi() warning from 64-bit implementation of vmalloc_fault() Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 077/244] mlxsw: spectrum_router: Prevent ipv6 gateway with v4 route via replace and append Sasha Levin
2019-05-22 19:29   ` David Ahern
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 078/244] mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 079/244] Bluetooth: hci_qca: Give enough time to ROME controller to bootup Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 080/244] HID: logitech-hidpp: use RAP instead of FAP to get the protocol version Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 081/244] pinctrl: pistachio: fix leaked of_node references Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 082/244] pinctrl: samsung: " Sasha Levin
2019-05-22 19:23 ` [PATCH AUTOSEL 4.19 083/244] clk: rockchip: undo several noc and special clocks as critical on rk3288 Sasha Levin
2019-05-22 19:23   ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190522192630.24917-53-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.