linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Zheyu Ma <zheyuma97@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-serial@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 14/59] tty: serial: jsm: hold port lock when reporting modem line changes
Date: Thu,  9 Sep 2021 07:58:15 -0400	[thread overview]
Message-ID: <20210909115900.149795-14-sashal@kernel.org> (raw)
In-Reply-To: <20210909115900.149795-1-sashal@kernel.org>

From: Zheyu Ma <zheyuma97@gmail.com>

[ Upstream commit 240e126c28df084222f0b661321e8e3ecb0d232e ]

uart_handle_dcd_change() requires a port lock to be held and will emit a
warning when lockdep is enabled.

Held corresponding lock to fix the following warnings.

[  132.528648] WARNING: CPU: 5 PID: 11600 at drivers/tty/serial/serial_core.c:3046 uart_handle_dcd_change+0xf4/0x120
[  132.530482] Modules linked in:
[  132.531050] CPU: 5 PID: 11600 Comm: jsm Not tainted 5.14.0-rc1-00003-g7fef2edf7cc7-dirty #31
[  132.535268] RIP: 0010:uart_handle_dcd_change+0xf4/0x120
[  132.557100] Call Trace:
[  132.557562]  ? __free_pages+0x83/0xb0
[  132.558213]  neo_parse_modem+0x156/0x220
[  132.558897]  neo_param+0x399/0x840
[  132.559495]  jsm_tty_open+0x12f/0x2d0
[  132.560131]  uart_startup.part.18+0x153/0x340
[  132.560888]  ? lock_is_held_type+0xe9/0x140
[  132.561660]  uart_port_activate+0x7f/0xe0
[  132.562351]  ? uart_startup.part.18+0x340/0x340
[  132.563003]  tty_port_open+0x8d/0xf0
[  132.563523]  ? uart_set_options+0x1e0/0x1e0
[  132.564125]  uart_open+0x24/0x40
[  132.564604]  tty_open+0x15c/0x630

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Link: https://lore.kernel.org/r/1626242003-3809-1-git-send-email-zheyuma97@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/tty/serial/jsm/jsm_neo.c | 2 ++
 drivers/tty/serial/jsm/jsm_tty.c | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
index c6fdd6369534..96e01bf4599c 100644
--- a/drivers/tty/serial/jsm/jsm_neo.c
+++ b/drivers/tty/serial/jsm/jsm_neo.c
@@ -827,7 +827,9 @@ static void neo_parse_isr(struct jsm_board *brd, u32 port)
 		/* Parse any modem signal changes */
 		jsm_dbg(INTR, &ch->ch_bd->pci_dev,
 			"MOD_STAT: sending to parse_modem_sigs\n");
+		spin_lock_irqsave(&ch->uart_port.lock, lock_flags);
 		neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr));
+		spin_unlock_irqrestore(&ch->uart_port.lock, lock_flags);
 	}
 }
 
diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index ec7d8383900f..7c790ff6b511 100644
--- a/drivers/tty/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
@@ -195,6 +195,7 @@ static void jsm_tty_break(struct uart_port *port, int break_state)
 
 static int jsm_tty_open(struct uart_port *port)
 {
+	unsigned long lock_flags;
 	struct jsm_board *brd;
 	struct jsm_channel *channel =
 		container_of(port, struct jsm_channel, uart_port);
@@ -248,6 +249,7 @@ static int jsm_tty_open(struct uart_port *port)
 	channel->ch_cached_lsr = 0;
 	channel->ch_stops_sent = 0;
 
+	spin_lock_irqsave(&port->lock, lock_flags);
 	termios = &port->state->port.tty->termios;
 	channel->ch_c_cflag	= termios->c_cflag;
 	channel->ch_c_iflag	= termios->c_iflag;
@@ -267,6 +269,7 @@ static int jsm_tty_open(struct uart_port *port)
 	jsm_carrier(channel);
 
 	channel->ch_open_count++;
+	spin_unlock_irqrestore(&port->lock, lock_flags);
 
 	jsm_dbg(OPEN, &channel->ch_bd->pci_dev, "finish\n");
 	return 0;
-- 
2.30.2


  parent reply	other threads:[~2021-09-09 13:20 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09 11:58 [PATCH AUTOSEL 4.14 01/59] media: dib8000: rewrite the init prbs logic Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 02/59] crypto: mxs-dcp - Use sg_mapping_iter to copy data Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 03/59] PCI: Use pci_update_current_state() in pci_enable_device_flags() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 04/59] iio: dac: ad5624r: Fix incorrect handling of an optional regulator Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 05/59] ARM: dts: qcom: apq8064: correct clock names Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 06/59] video: fbdev: kyro: fix a DoS bug by restricting user input Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 07/59] netlink: Deal with ESRCH error in nlmsg_notify() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 08/59] Smack: Fix wrong semantics in smk_access_entry() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 09/59] usb: host: fotg210: fix the endpoint's transactional opportunities calculation Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 10/59] usb: host: fotg210: fix the actual_length of an iso packet Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 11/59] usb: gadget: u_ether: fix a potential null pointer dereference Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 12/59] usb: gadget: composite: Allow bMaxPower=0 if self-powered Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 13/59] staging: board: Fix uninitialized spinlock when attaching genpd Sasha Levin
2021-09-09 11:58 ` Sasha Levin [this message]
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 15/59] bpf/tests: Fix copy-and-paste error in double word test Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 16/59] bpf/tests: Do not PASS tests without actually testing the result Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 17/59] video: fbdev: asiliantfb: Error out if 'pixclock' equals zero Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 18/59] video: fbdev: kyro: " Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 19/59] video: fbdev: riva: " Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 20/59] ipv4: ip_output.c: Fix out-of-bounds warning in ip_copy_addrs() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 21/59] flow_dissector: Fix out-of-bounds warnings Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 22/59] s390/jump_label: print real address in a case of a jump label bug Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 23/59] serial: 8250: Define RX trigger levels for OxSemi 950 devices Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 24/59] xtensa: ISS: don't panic in rs_init Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 25/59] hvsi: don't panic on tty_register_driver failure Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 26/59] serial: 8250_pci: make setup_port() parameters explicitly unsigned Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 27/59] staging: ks7010: Fix the initialization of the 'sleep_status' structure Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 28/59] ata: sata_dwc_460ex: No need to call phy_exit() befre phy_init() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 29/59] Bluetooth: skip invalid hci_sync_conn_complete_evt Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 30/59] ASoC: Intel: bytcr_rt5640: Move "Platform Clock" routes to the maps for the matching in-/output Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 31/59] bpf: Fix off-by-one in tail call count limiting Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 32/59] media: v4l2-dv-timings.c: fix wrong condition in two for-loops Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 33/59] arm64: dts: qcom: sdm660: use reg value for memory node Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 34/59] net: ethernet: stmmac: Do not use unreachable() in ipq806x_gmac_probe() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 35/59] Bluetooth: avoid circular locks in sco_sock_connect Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 36/59] gpu: drm: amd: amdgpu: amdgpu_i2c: fix possible uninitialized-variable access in amdgpu_i2c_router_select_ddc_port() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 37/59] ARM: tegra: tamonten: Fix UART pad setting Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 38/59] ACPICA: iASL: Fix for WPBT table with no command-line arguments Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 39/59] rpc: fix gss_svc_init cleanup on failure Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 40/59] staging: rts5208: Fix get_ms_information() heap buffer size Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 41/59] gfs2: Don't call dlm after protocol is unmounted Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 42/59] btrfs: subpage: check if there are compressed extents inside one page Sasha Levin
2021-09-09 13:01   ` David Sterba
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 43/59] btrfs: subpage: fix race between prepare_pages() and btrfs_releasepage() Sasha Levin
2021-09-09 13:01   ` David Sterba
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 44/59] ASoC: intel: atom: Revert PCM buffer address setup workaround again Sasha Levin
2021-09-09 12:06   ` Takashi Iwai
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 45/59] mmc: sdhci-of-arasan: Check return value of non-void funtions Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 46/59] mmc: rtsx_pci: Fix long reads when clock is prescaled Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 47/59] selftests/bpf: Enlarge select() timeout for test_maps Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 48/59] cifs: fix wrong release in sess_alloc_buffer() failed path Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 49/59] Revert "USB: xhci: fix U1/U2 handling for hardware with XHCI_INTEL_HOST quirk set" Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 50/59] usb: musb: musb_dsps: request_irq() after initializing musb Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 51/59] usbip: give back URBs for unsent unlink requests during cleanup Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 52/59] usbip:vhci_hcd USB port can get stuck in the disabled state Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 53/59] ASoC: rockchip: i2s: Fix regmap_ops hang Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 54/59] ASoC: rockchip: i2s: Fixup config for DAIFMT_DSP_A/B Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 55/59] parport: remove non-zero check on count Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 56/59] ath9k: fix OOB read ar9300_eeprom_restore_internal Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 57/59] ath9k: fix sleeping in atomic context Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 58/59] net: fix NULL pointer reference in cipso_v4_doi_free Sasha Levin
2021-09-09 11:59 ` [PATCH AUTOSEL 4.14 59/59] net: w5100: check return value after calling platform_get_resource() 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=20210909115900.149795-14-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=zheyuma97@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).