From: Jiri Slaby <jirislaby@kernel.org>
To: Sasha Levin <sashal@kernel.org>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Daniel Starke <daniel.starke@siemens.com>,
kernel test robot <lkp@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH AUTOSEL 5.15 34/47] tty: n_gsm: replace use of gsm_read_ea() with gsm_read_ea_val()
Date: Thu, 13 Oct 2022 08:21:37 +0200 [thread overview]
Message-ID: <df8b824a-5479-0593-4f87-7ac8317584fa@kernel.org> (raw)
In-Reply-To: <20221013002124.1894077-34-sashal@kernel.org>
On 13. 10. 22, 2:21, Sasha Levin wrote:
> From: Daniel Starke <daniel.starke@siemens.com>
>
> [ Upstream commit 669609cea1d294f43efdd8d57ab65927df90e6df ]
>
> Replace the use of gsm_read_ea() with gsm_read_ea_val() where applicable to
> improve code readability and avoid errors like in the past. See first link
> below for reference.
I don't think this warrants for stable. It's only a cleanup, not a fix.
And it's quite intrusive.
> Link: https://lore.kernel.org/all/20220504081733.3494-1-daniel.starke@siemens.com/
> Link: https://lore.kernel.org/all/202208222147.WfFRmf1r-lkp@intel.com/
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
> Link: https://lore.kernel.org/r/20220831073800.7459-3-daniel.starke@siemens.com
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> drivers/tty/n_gsm.c | 95 ++++++++++++++++++++++-----------------------
> 1 file changed, 47 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
> index 154697be11b0..d27247a84aab 100644
> --- a/drivers/tty/n_gsm.c
> +++ b/drivers/tty/n_gsm.c
> @@ -1297,18 +1297,12 @@ static void gsm_control_modem(struct gsm_mux *gsm, const u8 *data, int clen)
> unsigned int modem = 0;
> struct gsm_dlci *dlci;
> int len = clen;
> - int slen;
> + int cl = clen;
> const u8 *dp = data;
> struct tty_struct *tty;
>
> - while (gsm_read_ea(&addr, *dp++) == 0) {
> - len--;
> - if (len == 0)
> - return;
> - }
> - /* Must be at least one byte following the EA */
> - len--;
> - if (len <= 0)
> + len = gsm_read_ea_val(&addr, data, cl);
> + if (len < 1)
> return;
>
> addr >>= 1;
> @@ -1317,15 +1311,20 @@ static void gsm_control_modem(struct gsm_mux *gsm, const u8 *data, int clen)
> return;
> dlci = gsm->dlci[addr];
>
> - slen = len;
> - while (gsm_read_ea(&modem, *dp++) == 0) {
> - len--;
> - if (len == 0)
> - return;
> - }
> - len--;
> + /* Must be at least one byte following the EA */
> + if ((cl - len) < 1)
> + return;
> +
> + dp += len;
> + cl -= len;
> +
> + /* get the modem status */
> + len = gsm_read_ea_val(&modem, dp, cl);
> + if (len < 1)
> + return;
> +
> tty = tty_port_tty_get(&dlci->port);
> - gsm_process_modem(tty, dlci, modem, slen - len);
> + gsm_process_modem(tty, dlci, modem, cl);
> if (tty) {
> tty_wakeup(tty);
> tty_kref_put(tty);
> @@ -1819,11 +1818,10 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, const u8 *data, int clen)
> struct tty_port *port = &dlci->port;
> struct tty_struct *tty;
> unsigned int modem = 0;
> - int len = clen;
> - int slen = 0;
> + int len;
>
> if (debug & 16)
> - pr_debug("%d bytes for tty\n", len);
> + pr_debug("%d bytes for tty\n", clen);
> switch (dlci->adaption) {
> /* Unsupported types */
> case 4: /* Packetised interruptible data */
> @@ -1831,24 +1829,22 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, const u8 *data, int clen)
> case 3: /* Packetised uininterruptible voice/data */
> break;
> case 2: /* Asynchronous serial with line state in each frame */
> - while (gsm_read_ea(&modem, *data++) == 0) {
> - len--;
> - slen++;
> - if (len == 0)
> - return;
> - }
> - len--;
> - slen++;
> + len = gsm_read_ea_val(&modem, data, clen);
> + if (len < 1)
> + return;
> tty = tty_port_tty_get(port);
> if (tty) {
> - gsm_process_modem(tty, dlci, modem, slen);
> + gsm_process_modem(tty, dlci, modem, len);
> tty_wakeup(tty);
> tty_kref_put(tty);
> }
> + /* Skip processed modem data */
> + data += len;
> + clen -= len;
> fallthrough;
> case 1: /* Line state will go via DLCI 0 controls only */
> default:
> - tty_insert_flip_string(port, data, len);
> + tty_insert_flip_string(port, data, clen);
> tty_flip_buffer_push(port);
> }
> }
> @@ -1869,24 +1865,27 @@ static void gsm_dlci_command(struct gsm_dlci *dlci, const u8 *data, int len)
> {
> /* See what command is involved */
> unsigned int command = 0;
> - while (len-- > 0) {
> - if (gsm_read_ea(&command, *data++) == 1) {
> - int clen = *data++;
> - len--;
> - /* FIXME: this is properly an EA */
> - clen >>= 1;
> - /* Malformed command ? */
> - if (clen > len)
> - return;
> - if (command & 1)
> - gsm_control_message(dlci->gsm, command,
> - data, clen);
> - else
> - gsm_control_response(dlci->gsm, command,
> - data, clen);
> - return;
> - }
> - }
> + unsigned int clen = 0;
> + unsigned int dlen;
> +
> + /* read the command */
> + dlen = gsm_read_ea_val(&command, data, len);
> + len -= dlen;
> + data += dlen;
> +
> + /* read any control data */
> + dlen = gsm_read_ea_val(&clen, data, len);
> + len -= dlen;
> + data += dlen;
> +
> + /* Malformed command? */
> + if (clen > len)
> + return;
> +
> + if (command & 1)
> + gsm_control_message(dlci->gsm, command, data, clen);
> + else
> + gsm_control_response(dlci->gsm, command, data, clen);
> }
>
> /**
--
js
suse labs
next prev parent reply other threads:[~2022-10-13 6:21 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 0:20 [PATCH AUTOSEL 5.15 01/47] clk: zynqmp: Fix stack-out-of-bounds in strncpy` Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 02/47] media: cx88: Fix a null-ptr-deref bug in buffer_prepare() Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 03/47] media: platform: fix some double free in meson-ge2d and mtk-jpeg and s5p-mfc Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 04/47] clk: zynqmp: pll: rectify rate rounding in zynqmp_pll_round_rate Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 05/47] usb: host: xhci-plat: suspend and resume clocks Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 06/47] usb: host: xhci-plat: suspend/resume clks for brcm Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 07/47] dmaengine: ti: k3-udma: Reset UDMA_CHAN_RT byte counters to prevent overflow Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 08/47] scsi: 3w-9xxx: Avoid disabling device if failing to enable it Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 09/47] nbd: Fix hung when signal interrupts nbd_start_device_ioctl() Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 10/47] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity Sasha Levin
2022-10-13 7:07 ` John Garry
2022-10-16 13:30 ` Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 11/47] staging: rtl8712: Fix return type for implementation of ndo_start_xmit Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 12/47] staging: rtl8192e: " Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 13/47] power: supply: adp5061: fix out-of-bounds read in adp5061_get_chg_type() Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 14/47] staging: vt6655: fix potential memory leak Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 15/47] blk-throttle: prevent overflow while calculating wait time Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 16/47] gpiolib: of: do not ignore requested index when applying quirks Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 17/47] gpiolib: of: make Freescale SPI quirk similar to all others Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 18/47] gpiolib: rework quirk handling in of_find_gpio() Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 19/47] ata: libahci_platform: Sanity check the DT child nodes number Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 20/47] bcache: fix set_at_max_writeback_rate() for multiple attached devices Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 21/47] soundwire: cadence: Don't overwrite msg->buf during write commands Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 22/47] soundwire: intel: fix error handling on dai registration issues Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 23/47] hid: topre: Add driver fixing report descriptor Sasha Levin
2022-10-13 0:20 ` [PATCH AUTOSEL 5.15 24/47] habanalabs: remove some f/w descriptor validations Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 25/47] HID: roccat: Fix use-after-free in roccat_read() Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 26/47] HSI: ssi_protocol: fix potential resource leak in ssip_pn_open() Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 27/47] eventfd: guard wake_up in eventfd fs calls as well Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 28/47] md/raid5: Wait for MD_SB_CHANGE_PENDING in raid5d Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 29/47] usb: host: xhci: Fix potential memory leak in xhci_alloc_stream_info() Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 30/47] usb: musb: Fix musb_gadget.c rxstate overflow bug Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 31/47] arm64: dts: imx8mp: Add snps,gfladj-refclk-lpm-sel quirk to USB nodes Sasha Levin
2022-10-13 5:57 ` [PATCH AUTOSEL 5.15 31/47] arm64: dts: imx8mp: Add snps, gfladj-refclk-lpm-sel " Alexander Stein
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 32/47] usb: dwc3: core: Enable GUCTL1 bit 10 for fixing termination error after resume bug Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 33/47] Revert "usb: storage: Add quirk for Samsung Fit flash" Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 34/47] tty: n_gsm: replace use of gsm_read_ea() with gsm_read_ea_val() Sasha Levin
2022-10-13 6:21 ` Jiri Slaby [this message]
2022-10-16 13:27 ` Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 35/47] staging: rtl8723bs: fix potential memory leak in rtw_init_drv_sw() Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 36/47] staging: rtl8723bs: fix a potential memory leak in rtw_init_cmd_priv() Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 37/47] staging: rtl8192u: Fix return type of ieee80211_xmit Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 38/47] staging: octeon: Fix return type of cvm_oct_xmit and cvm_oct_xmit_pow Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 39/47] scsi: tracing: Fix compile error in trace_array calls when TRACING is disabled Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 40/47] ext2: Use kvmalloc() for group descriptor array Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 41/47] nvme: copy firmware_rev on each init Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 42/47] nvmet-tcp: add bounds check on Transfer Tag Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 43/47] usb: idmouse: fix an uninit-value in idmouse_open Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 44/47] fsi: master-ast-cf: Fix missing of_node_put in fsi_master_acf_probe Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 45/47] sbitmap: fix lockup while swapping Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 46/47] clk: bcm2835: Make peripheral PLLC critical Sasha Levin
2022-10-13 0:21 ` [PATCH AUTOSEL 5.15 47/47] clk: bcm2835: Round UART input clock up 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=df8b824a-5479-0593-4f87-7ac8317584fa@kernel.org \
--to=jirislaby@kernel.org \
--cc=daniel.starke@siemens.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=sashal@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox