From patchwork Tue May 17 11:07:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 573644 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 985C5C433FE for ; Tue, 17 May 2022 11:08:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234372AbiEQLIB (ORCPT ); Tue, 17 May 2022 07:08:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344899AbiEQLH7 (ORCPT ); Tue, 17 May 2022 07:07:59 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B6E419020; Tue, 17 May 2022 04:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652785677; x=1684321677; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OPXJ4evp1SveqnRrI1ZxE35Iny9xfr/vhM5iE/upNFU=; b=WX0H/gnkazyTGL/0gOV4I5YSFaOZAAsoSeEEv5PoLpx5p428FWvZ0rZ4 CDKiLeTMqCJgbUYl/FL64TQxSqoYMQU0UyRRSbkZwArIKICNTVQq+dA2N 4V8HQeWl6KICtsrCOc6UX2RVr/XIcfkg51r0SP0MwcpZ9xp643aCm4CtE vVSVMftrv4PfOOzjOAs05QPM4vKeMzrYKqvFK/q3bTS3dOaWfBTU43WGs YfR3KUUJc1hFjewPT+o6KuoUUC0gP19be954vIBzC9/eHgP4AOV0LKp3u VY4kl7JSxWZF6SfqILlHf0QV5Xia6jckfVujC/783/uU6aLTZPulR/Aql A==; X-IronPort-AV: E=McAfee;i="6400,9594,10349"; a="271268665" X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="271268665" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 04:07:57 -0700 X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="568830894" Received: from mtarral-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.52.88]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 04:07:54 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg KH , Jiri Slaby , Peter Korsgaard , Sean Anderson , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 1/9] serial: uartline: Fix BRKINT clearing Date: Tue, 17 May 2022 14:07:29 +0300 Message-Id: <20220517110737.37148-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220517110737.37148-1-ilpo.jarvinen@linux.intel.com> References: <20220517110737.37148-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org BRKINT is within c_iflag rather than c_cflag. Cc: Sean Anderson Fixes: ea017f5853e9 (tty: serial: uartlite: Prevent changing fixed parameters) Signed-off-by: Ilpo Järvinen --- drivers/tty/serial/uartlite.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c index 007db67292a2..880e2afbb97b 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c @@ -321,7 +321,8 @@ static void ulite_set_termios(struct uart_port *port, struct ktermios *termios, struct uartlite_data *pdata = port->private_data; /* Set termios to what the hardware supports */ - termios->c_cflag &= ~(BRKINT | CSTOPB | PARENB | PARODD | CSIZE); + termios->c_iflag &= ~BRKINT; + termios->c_cflag &= ~(CSTOPB | PARENB | PARODD | CSIZE); termios->c_cflag |= pdata->cflags & (PARENB | PARODD | CSIZE); tty_termios_encode_baud_rate(termios, pdata->baud, pdata->baud); From patchwork Tue May 17 11:07:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 573643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00779C433F5 for ; Tue, 17 May 2022 11:08:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344953AbiEQLIU (ORCPT ); Tue, 17 May 2022 07:08:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344913AbiEQLIG (ORCPT ); Tue, 17 May 2022 07:08:06 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD238AE5D; Tue, 17 May 2022 04:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652785685; x=1684321685; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3rLSxMemifcCya5x4k0dLXnkqmQGBK5a9aBX6E+21uY=; b=UUt4+BRkbxWSsok34aBghj8DiGpTDRGeC9utQb9I49TEH5Du1/ZcxRVf rypfTainHbzWUU+smztuquLn4s4qQCpmwl8KseYzuYuQEW/9goCxYVAgK +M5f2il5e0r1+f6hZGX867GQfkQV7s+m4daJpcDK5CZ+Yj9UOUqkfGqjx G6bhdSYG76JYHktjUdw8KvklEwuvYdyu6RBTrAXZb8kHKNJ/BN/eRx7qu uUbcaRKTMt0CH4oPUr1TO+u+AV4bjr+z5njfFCNCJqvPaPO4MkOOElytE 4X66kyjB34o7OnBKkonNB3lx8oZPo2KOQ/ZwqFea2w8NauaN/AEk0pswE A==; X-IronPort-AV: E=McAfee;i="6400,9594,10349"; a="271268701" X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="271268701" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 04:08:05 -0700 X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="568830979" Received: from mtarral-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.52.88]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 04:08:01 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg KH , Jiri Slaby , Manivannan Sadhasivam , Olof Johansson , =?utf-8?q?Andreas_F=C3=A4rber?= , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-unisoc@lists.infradead.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 3/9] serial: rda-uart: Don't allow CS5-6 Date: Tue, 17 May 2022 14:07:31 +0300 Message-Id: <20220517110737.37148-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220517110737.37148-1-ilpo.jarvinen@linux.intel.com> References: <20220517110737.37148-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Only CS7 and CS8 are supported but CSIZE is not sanitized after fallthrough from CS5 or CS6 to CS7. Set CSIZE correctly so that userspace knows the effective value. Incorrect CSIZE also results in miscalculation of the frame bits in tty_get_char_size() or in its predecessor where the roughly the same code is directly within uart_update_timeout(). Cc: Manivannan Sadhasivam Fixes: c10b13325ced (tty: serial: Add RDA8810PL UART driver) Signed-off-by: Ilpo Järvinen --- drivers/tty/serial/rda-uart.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/rda-uart.c b/drivers/tty/serial/rda-uart.c index e5f1fded423a..f556b4955f59 100644 --- a/drivers/tty/serial/rda-uart.c +++ b/drivers/tty/serial/rda-uart.c @@ -262,6 +262,8 @@ static void rda_uart_set_termios(struct uart_port *port, fallthrough; case CS7: ctrl &= ~RDA_UART_DBITS_8; + termios->c_cflag &= ~CSIZE; + termios->c_cflag |= CS7; break; default: ctrl |= RDA_UART_DBITS_8; From patchwork Tue May 17 11:07:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 573642 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32953C433F5 for ; Tue, 17 May 2022 11:08:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345029AbiEQLIa (ORCPT ); Tue, 17 May 2022 07:08:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344980AbiEQLIV (ORCPT ); Tue, 17 May 2022 07:08:21 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DEF824F39; Tue, 17 May 2022 04:08:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652785693; x=1684321693; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=E3zjirNqG/3LyQnmY81zuizX47Uw5UxNaZ0Aqf8btHo=; b=WVLwodI3HZ54Wdunq1nMviUJBBQ9P4DVzBbKeYf2ScSYtricDpm5G+Ps VX9kOdJfqQ2s9F3bdc5l3GAUHFxOTwJ8fdrK7tW5EgrPo/6utClKKEtXR 90BFjpjY9i1AhnXayDBBdFPTLD7w+7qD+DlZtcQhI8jxoEeH6arsm+Ds9 REIdI1ytsbbRa0UJoDjEZSJ9wpdUQczUNFo0o5dlM69zQv4J2aBcVtM6i FilfRUvGgDeC9HbEZDid+7QIfJZWo+d1jipsdyBn/hY7RmM536Frwv2RA VBStFLeKAP+xXN1h4VN29yA1TU/vs+7SmRHC7li4rdEkOG7YyZF3xHxWR w==; X-IronPort-AV: E=McAfee;i="6400,9594,10349"; a="271268752" X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="271268752" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 04:08:13 -0700 X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="568831080" Received: from mtarral-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.52.88]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 04:08:11 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg KH , Jiri Slaby , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 5/9] serial: sh-sci: Don't allow CS5-6 Date: Tue, 17 May 2022 14:07:33 +0300 Message-Id: <20220517110737.37148-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220517110737.37148-1-ilpo.jarvinen@linux.intel.com> References: <20220517110737.37148-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Only CS7 and CS8 seem supported but CSIZE is not sanitized from CS5 or CS6 to CS8. Set CSIZE correctly so that userspace knows the effective value. Incorrect CSIZE also results in miscalculation of the frame bits in tty_get_char_size() or in its predecessor where the roughly the same code is directly within uart_update_timeout(). Fixes: 1da177e4c3f4 (Linux-2.6.12-rc2) Signed-off-by: Ilpo Järvinen --- drivers/tty/serial/sh-sci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 0f9b8bd23500..0075a1420005 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -2379,8 +2379,12 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, int best_clk = -1; unsigned long flags; - if ((termios->c_cflag & CSIZE) == CS7) + if ((termios->c_cflag & CSIZE) == CS7) { smr_val |= SCSMR_CHR; + } else { + termios->c_cflag &= ~CSIZE; + termios->c_cflag |= CS8; + } if (termios->c_cflag & PARENB) smr_val |= SCSMR_PE; if (termios->c_cflag & PARODD) From patchwork Tue May 17 11:07:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 573641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE222C433F5 for ; Tue, 17 May 2022 11:08:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344934AbiEQLIx (ORCPT ); Tue, 17 May 2022 07:08:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344950AbiEQLI1 (ORCPT ); Tue, 17 May 2022 07:08:27 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68D516452; Tue, 17 May 2022 04:08:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652785701; x=1684321701; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XUGgIusaR1c/M+hdwMIEtCQbJlvmDStPf6Do24whbYo=; b=g0SGF6+1jLD5ChJNsN/azBflOJ9omaDJW09IIEkJHTpP7NqnBn62X7l3 um7fK98AdOShq7wLDsVCnm3pZwAAUSeJZU4k0VSDS4xlYmrMIO52gBIzT 8dGIsblieR2w2rM35Rug+quTv86jIzL2eKHSsXBb7YsAObSFyhgRhIpWx jfYsyTDmbcSPi8scXnuBrtnfn6hltkHXuZdL7OhfbGLOhLj/kt8G58w8F uiBw/vVIiwlopvQFYfPO+qzn5fDBttMcxvkh7aLdu0orgBx9RFrAxDBJX JJqw0SGjdoCPL2NrkXvas1PD3SsqoKIEYzYLvnvsNkKDW/wQERFwSA87A w==; X-IronPort-AV: E=McAfee;i="6400,9594,10349"; a="271268777" X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="271268777" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 04:08:21 -0700 X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="568831117" Received: from mtarral-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.52.88]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 04:08:18 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg KH , Jiri Slaby , Patrice Chotard , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 7/9] serial: st-asc: Sanitize CSIZE and correct PARENB for CS7 Date: Tue, 17 May 2022 14:07:35 +0300 Message-Id: <20220517110737.37148-8-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220517110737.37148-1-ilpo.jarvinen@linux.intel.com> References: <20220517110737.37148-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Only CS7 and CS8 seem supported but CSIZE is not sanitized from CS5 or CS6 to CS8. In addition, ASC_CTL_MODE_7BIT_PAR suggests that CS7 has to have parity, thus add PARENB. Incorrect CSIZE results in miscalculation of the frame bits in tty_get_char_size() or in its predecessor where the roughly the same code is directly within uart_update_timeout(). Cc: Srinivas Kandagatla Fixes: c4b058560762 (serial:st-asc: Add ST ASC driver.) Signed-off-by: Ilpo Järvinen --- drivers/tty/serial/st-asc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c index d7fd692286cf..1b0da603ab54 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c @@ -535,10 +535,14 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios, /* set character length */ if ((cflag & CSIZE) == CS7) { ctrl_val |= ASC_CTL_MODE_7BIT_PAR; + cflag |= PARENB; } else { ctrl_val |= (cflag & PARENB) ? ASC_CTL_MODE_8BIT_PAR : ASC_CTL_MODE_8BIT; + cflag &= ~CSIZE; + cflag |= CS8; } + termios->c_cflag = cflag; /* set stop bit */ ctrl_val |= (cflag & CSTOPB) ? ASC_CTL_STOP_2BIT : ASC_CTL_STOP_1BIT; From patchwork Tue May 17 11:07:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 573640 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BECF5C433F5 for ; Tue, 17 May 2022 11:09:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345043AbiEQLJg (ORCPT ); Tue, 17 May 2022 07:09:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344985AbiEQLIg (ORCPT ); Tue, 17 May 2022 07:08:36 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 309D62DABA; Tue, 17 May 2022 04:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652785711; x=1684321711; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nQ+lnY6dYx8GIiIqMS+NqyRc9HSpuylhm5ub7+G+Sro=; b=CxWEBRFnwuGMk//GWb0esBq7Gonnjr/PxnOHH4jgL/UiIp4j4MzYtary H0Kmf6zL94RFjpTkHE0eZCzt2RdZPY5K6pTtfwIpocXedbpKTrzoHfOuJ n8xbua6TAmVgsqQZ76K8TZdxHO3hLJdfsOnBTQoWv6YlZPgNW0Tk3XVDZ 7QBnZzx5xzkvRBQyi83tXVbNoNbuL5Uk0UDhylAN4MuNXu5kZxu7idmWC YNF0UihJf1HSXHnVN2GqV9c/xoaQcifWCw4mmi34srIh36h/fpxDwx5WR WeoyB4HmkDzOMN8AckHkgL67VvbVJVoxKECUV0uh1yLOBBrZF93V8bu6O Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10349"; a="271268802" X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="271268802" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 04:08:30 -0700 X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="568831154" Received: from mtarral-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.52.88]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 04:08:26 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg KH , Jiri Slaby , Arnd Bergmann , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 9/9] pcmcia: synclink_cs: Don't allow CS5-6 Date: Tue, 17 May 2022 14:07:37 +0300 Message-Id: <20220517110737.37148-10-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220517110737.37148-1-ilpo.jarvinen@linux.intel.com> References: <20220517110737.37148-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Only CS7 and CS8 seem supported but CSIZE was not sanitized in termios c_cflag. The driver sets 7 bits whenever data_bits is not 8 so default to CS7 when CSIZE is not CS8. Signed-off-by: Ilpo Järvinen --- drivers/char/pcmcia/synclink_cs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 78baba55a8b5..d0572bbe8832 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -1418,7 +1418,11 @@ static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty) info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); /* byte size and parity */ - + if ((cflag & CSIZE) != CS8) { + cflag &= ~CSIZE; + cflag |= CS7; + tty->termios.c_cflag = cflag; + } info->params.data_bits = tty_get_char_size(cflag); if (cflag & CSTOPB)